I am using below code for leaving the current page. It works fine in chrome and mozilla, but it is calling for every anchor tags in IE 10 browser. What can I do to prevent calling this in IE 10 browser?
window.onbeforeunload = function()
{
return "";
};
this is default behavior of IE, you need to remove onbeforeunload event from anchor tag while you are hovering over it:
$(document).ready(function(){
//store onbeforeunload for later use
$(window).data('beforeunload',window.onbeforeunload);
//remove||re-assign onbeforeunload on hover
$('a')
.hover(
function(){window.onbeforeunload=null;},
function(){window.onbeforeunload=$(window).data('beforeunload');}
);
});
Or you need to 'return false' onClick event of each anchor tag:
<a onclick="someFunction(); return false;" href="lnk" >my link</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With