Onbeforeunload To Redirect User
In my OnBeforeUnload event, it asked the user whether they want to leave the page or stay on it. When they click 'stay on page', I want it to then redirect them to another webpage
Solution 1:
Interesting!
Possible in Internet Explorer:
window.onbeforeunload = function()
{
window.onbeforeunload = null;
location.assign('http://example.com');
return"Warning message";
};
Firefox will go to the second page whilst waiting for your answer and then leave the page if you say so.
Chrome will always go to the second page, meaning the user cannot leave the page. So this might be a fantastically bad idea.
If the user is closing their window, it works alright though - but you can't tell if this is what the user wants.
Post a Comment for "Onbeforeunload To Redirect User"