最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - cross-browser Onunload and Onbeforeunload ? (particularly opera 11) - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question edited Jan 13, 2011 at 17:51 rsk82 asked Jan 13, 2011 at 17:39 rsk82rsk82 29.4k54 gold badges156 silver badges245 bronze badges 1
  • possible duplicate of onbeforeunload in Opera – Bergi Commented Mar 26, 2013 at 22:53
Add a comment  | 

4 Answers 4

Reset to default 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.

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.

onbeforeunload is now supported since Opera 15 !

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

发布评论

评论列表(0)

  1. 暂无评论