Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
324 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...