onbeforeunload in Opera

情到浓时终转凉″ 提交于 2019-11-26 21:47:37

问题


I'm using the code that netadictos posted to the question here. All I want to do is to display a warning when a user is navigating away from or closing a window/tab.

The code that netadictos posted seems to work fine in IE7, FF 3.0.5, Safari 3.2.1, and Chrome but it doesn't work in Opera v9.63. Does anyone know of way of doing the same thing in Opera?

Thx, Trev


回答1:


onbeforeunload is now supported in Opera 15 based on the WebKit engine but not in any prior versions based on Presto.




回答2:


Opera does not support window.onbeforeunload at the moment. It will be supported in some future version, but has not been a sufficiently high priority to get implemented as of Opera 11.




回答3:


Have you tried this?

history.navigationMode = 'compatible';

Reference, found via this page

I haven't actually tried it myself, but it looks promising.




回答4:


Mobile Safari (iPhone/iPad) also doesn't support onbeforeunload, and I strongly suspect it is not likely to.

For detecting back/forward navigation there may be workarounds e.g. see Is there an alternative method to use onbeforeunload in mobile safari?.



来源:https://stackoverflow.com/questions/390260/onbeforeunload-in-opera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!