Los hipervínculos jQuery abren un enlace antes de mi evento onclick

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() {

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?

¡Muchas gracias por cualquier ayuda!

preguntado el 08 de noviembre de 11 a las 17:11

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")); }); -

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 :( -

This works! $('#myLink').click(function() { window.open($(this).attr("href")); event.preventDefault(); CloseQuoteOverlay(); }); -

makes sense...cool... cheers!! -

1 Respuestas

Eche un vistazo a este hilo: event.stopPropagation () no funciona en Chrome con jQuery 1.7

I helped him solve this exact issue.

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.