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

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

问题描述

可以依靠窗口卸载事件来触发用户关闭标签/窗口/浏览器吗?

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

编辑:

找到在IE中触发卸载事件的列表。 http://msdn.microsoft.com/en-我们/ 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不会触发卸载事件浏览器刷新页面,或使用后退/前进按钮浏览页面。更糟糕的是,Opera永远不会触发onb​​eforeunload事件。因此,如果您支持Opera - 请注意这些问题。

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天全站免登陆