1

In my popup page, I have a link with properties: id="myLink" href="http://..." target="_blank"

when user click the link, it should open the link as default event and then close the popup window.

I have following jquery code in the popup page to close popup window.

 $('#myLink').click(function() {
                ClosePopupOverlay();
            });

Now it works fine in IE, but in firefox and Chrome, it just close the popup window, doesn't open the link at all.

Can we not prevent default event and add custom code in jquery in all browsers? Any ideas on how to fix this issue?

Thanks a lot for any help!

lanlantu
  • 71
  • 1
  • 7
  • suggest trying e.preventDefault() method prehaps that will help the cause something like this: $('#myLink').click(function(e) { e.preventDefault(); ClosePopupOverlay(); window.open($("#mylink").attr("href")); }); – optimusprime619 Nov 08 '11 at 18:01
  • Thanks for your help! I tried your suggestion, it still work in IE but not in Firefox and Chrome. In Firefox and Chrome, when it finish ClosePopupOverlay,the following code can not run because the code reside on the page and page is closed. I tried to ClosePopupOverlay after window.open, doesn't work in the 2 browsers too. The focus in on the new opened window instead of the popup window, the following code can not run either :( – lanlantu Nov 08 '11 at 18:39
  • This works! $('#myLink').click(function() { window.open($(this).attr("href")); event.preventDefault(); CloseQuoteOverlay(); }); – lanlantu Nov 08 '11 at 18:52

1 Answers1

0

Have a look at this thread: event.stopPropagation() not working in chrome with jQuery 1.7

I helped him solve this exact issue.

Community
  • 1
  • 1
Sam
  • 15,336
  • 25
  • 85
  • 148