in IE - if you don't want the onbeforeunload
to trigger - all you need to do is to set this event to null
, like this:
window.onbeforeunload = null;
so what you would have to do is - add a click event listener to all your buttons and links (which redirect user to a different URI) and inside that listener - set the onbeforeunload
event listener to null
once they are clicked (before proceeding with the normal link/button action. Otherwise - set it to function (like you have in your code).
e.g.:
document.getElementById('myLink').onclick = function () {
window.onbeforeunload = null;
};