DOM窗口卸载事件,是它可靠吗? [英] DOM Window unload event, is it reliable?

查看:101
本文介绍了DOM窗口卸载事件,是它可靠吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以依靠窗口卸载事件,当用户关闭一个标签/窗口/浏览器?被触发

Can I rely on the window unload event to be triggered when a user closes a tab/window/browser?

编辑:

发现什么触发在IE卸载事件清单。 <一href=\"http://msdn.microsoft.com/en-us/library/ms536973%28VS.85%29.aspx\">http://msdn.microsoft.com/en-us/library/ms536973%28VS.85%29.aspx

Found a list of what triggers the unload event in IE. http://msdn.microsoft.com/en-us/library/ms536973%28VS.85%29.aspx

我想知道在哪个边缘的情况下卸载事件不会被触发。

I would like to know in which edge cases the unload event won't be triggered.

推荐答案

您可能会想使用的 onbeforeunload 事件太多,它提供了更多的控制比onunload的事件。

You will likely want to use the "onbeforeunload" event too, it provides more control than the "onunload" event.

这是说,请注意:当浏览器刷新页面,或使用后退/前进按钮浏览过的页面的Opera不触发unload事件。更糟的是,歌剧永远不会触发onb​​eforeunload事件。因此,如果要支持歌剧院 - 意识到这些问题。

That said, be aware that: Opera doesn’t fire the unload event when the browser refreshes the page, or uses the back/forward buttons to browse off of the page. What’s worse, Opera never fires the onbeforeunload event. Thus if you are supporting Opera - be aware of these issues.

这篇关于DOM窗口卸载事件,是它可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆