问题描述
我可以依靠窗口卸载事件,当用户关闭一个标签/窗口/浏览器?被触发
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-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.
推荐答案
您可能会想使用的事件太多,比onunload的事件。
You will likely want to use the "onbeforeunload" event too, it provides more control than the "onunload" event.
这是说,请注意:当浏览器刷新页面,或使用后退/前进按钮浏览过的页面的Opera不触发unload事件。更糟的是,歌剧永远不会触发onbeforeunload事件。因此,如果要支持歌剧院 - 意识到这些问题。
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窗口卸载事件,是它可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!