cross-browser Onunload and Onbeforeunload ? (particularly opera 11)
Asked Answered
M

4

7

I have a form and I must notice user with alert() on exiting page while there are data in the form that had not been send.

I've read that opera has a lot of problems with this. Opera 11 that is, because I need take into account only last version.

So again, the alert should display on refresh, closing a tab, or closing whole browser. It would be nice to set event directly to the <form> element that would be launched on anything that leads to destroying this element.

Message answered 13/1, 2011 at 17:39 Comment(1)
possible duplicate of onbeforeunload in OperaNewfeld
A
19

Opera does not yet support onbeforeunload. Opera's onunload support is incomplete - for example, it does not fire when you close a tab, or close Opera. As far as I know, while you can use onunload to show a warning if a user clicks a link to navigate away from a page with an unsaved form, there is no way you can prevent the navigation from happening when the unload event fires.

What I would do here is to listen for the onbeforeunload event, make it work in other browsers and wait for Opera to catch up. Whether it will be in Opera 12 or 13 or 15 I don't know, but when onbeforeunload is implemented it will work like it does in other browsers already.

Avidin answered 14/1, 2011 at 3:31 Comment(2)
Also Mobile Safari does not support onbeforeunload, so if you have any mobile users then you may need to find another solution.Tragedy
onbeforeunload is now supported in Opera 15 based on the Webkit engine!Kakalina
M
1

The Disable Close will not help you yet because Opera does not support window.onbeforeunload at the moment. It will be supported in some future version. For now, Opera 11 doesn't implement it.

Melissamelisse answered 13/1, 2011 at 18:41 Comment(0)
T
1

onbeforeunload is now supported since Opera 15 !

Trogon answered 12/5, 2014 at 11:38 Comment(0)
U
-5

The JQuery framework is only a condensed Javascript language so it depends entirely on the browser you use, no magic here.

Unfix answered 20/9, 2011 at 17:57 Comment(1)
How does this help towards the question?Pyroclastic

© 2022 - 2024 — McMap. All rights reserved.