Javascript: how to overwrite page reload event?
What I mean is - when user clicks on some browser page reload/refresh button we do not want to reload page - we want to capture that event and call some function (for simple example one with some alert). I need开发者_高级运维 it to work in IE6 and up and Chrome and Firefox3+ of course. How to do such thing (not using jQuery and other libs)?
It's not possible.
You can detect when an unload occurs, but you can't detect what caused the unload and you can't cancel it without the user's consent. For instance, typing a new address in the address box, clicking a link, submitting a form, selecting a bookmark or refreshing the page will all fire an onbeforeunload event.
You cannot. You can't change the operating system functionality from within any browser except IE.
精彩评论