onbeforeunload in Opera
Asked Answered
S

4

12

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

Shrine answered 23/12, 2008 at 22:35 Comment(0)
M
3

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

Mikvah answered 3/7, 2013 at 15:59 Comment(0)
B
12

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.

Belshazzar answered 22/12, 2010 at 12:19 Comment(0)
M
3

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

Mikvah answered 3/7, 2013 at 15:59 Comment(0)
D
1

Have you tried this?

history.navigationMode = 'compatible';

Reference, found via this page

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

Deloisedelong answered 23/12, 2008 at 22:58 Comment(2)
thx for the quick reply but, no, that doesn't seem to work. Even putting onunload="alert('hi');" in the body tag doesn't work in Opera.Shrine
If onunload doens't fix this, check if you have it disabled via: opera:config#UserPrefs|HistoryNavigationMode If not, then file bug with Opera: bugs.opera.com/wizard because presence of these handlers should disable DOM cache.Choral
N
1

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?.

Nakashima answered 12/7, 2012 at 4:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.