I have these line of code using onbeforeunload to ask user to save their data before closing the page. The code works well in Firefox & Chrome.
window.onbeforeunload = function () {
if (isUpdated) return "You have unsaved data";
else return undefined;
};
In IE (10), when I chose "Leave this page", everything's fine. But when I chose "Stay on this page", the popup closed and then display again, right after that, I have to click one more time on "Stay on this page", which I find annoying.
Anyone have a solution for this?
Add the
onbeforeunload
event handler towindow.href
instead ofwindow
: