Javascript, Can I "redirect" user in onbeforeunload? If cant, how to...
- by kanayaki
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 :(