开发者

Javascript: how to overwrite page reload event?

开发者 https://www.devze.com 2023-01-29 11:22 出处:网络
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 aler

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消