Javascript, Can I "redirect" user in onbeforeunload? If cant, how to...
Posted
by kanayaki
on Stack Overflow
See other posts from Stack Overflow
or by kanayaki
Published on 2009-09-11T04:07:28Z
Indexed on
2010/05/29
3:02 UTC
Read the original article
Hit count: 482
Is it possible to redirect to another page when userclose browser?
Attempts:
I tried onunload, does not work
window.onunload = function redirect(){...}
I also tried another method, it does not work as well:
window.onbeforeunload = redirect(){...}
<body onbeforeunload="return false; redirecty()">
The 3rd method, i want to cancel the onbeforeunload
(means delay closing the browser), the I call the redirect function, window.confirm
, if yes redirect, if no then close the browser. But it does not work as well.
Is there any other way?? Run out of ideas...
-- Prompt to let user select whether to redirect to new page when he/she close the browser --
This is the first time, I could not get best answer in stackoverflow :(
© Stack Overflow or respective owner