Reputation: 2654
I've seen a lot of question on this and the solution seems to be
window.onbeforeunload
But i've tried it, seems to work great to warn the user before the pages unload, but there is no way i've seems to be able to set the message in the message box.
i've tried this :
window.onbeforeunload = function (){ return "test";}
But I've got the default message of the browser.
I'm using the french version of firefox 8.0
Thanks all
Upvotes: 1
Views: 206
Reputation: 62027
Firefox does not allow you to change the message, but webkit (Chrome/Safari) does. In webkit, if you return a string, in your onbeforeunload
handler, it will interpret that as "pop a warning dialog" with your string as the message.
Sadly onbeforeunload is quite raw and not that great. Hopefully browsers figure out a better way to do this in the near future.
Upvotes: 2