WindowEventHandlers.onunload - Web APIs 编辑
The onunload
property of the WindowEventHandlers
mixin is the EventHandler
for processing unload
events. These events fire when the window is unloading its content and resources. The resource removal is processed after the unload
event occurs.
Note: Browsers equipped with pop-up blockers will ignore all Window.open()
method calls in onunload
event handler functions.
The onunload
(and the unload
event itself) are not the right features to use with sendBeacon()
. Instead for sendBeacon(),
use the visibilitychange
and pagehide
events. See discussion comments in the blog post Beacon API is broken.
Syntax
window.addEventListener("unload", function(event) { ... }); window.onunload = function(event) { ... };
Typically, it is better to use window.addEventListener()
and the unload
event, instead of onunload
.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'onunload' in that specification. | Living Standard | |
HTML 5.1 The definition of 'GlobalEventHandlers' in that specification. | Recommendation | |
HTML5 The definition of 'GlobalEventHandlers' in that specification. | Recommendation |
Browser compatibility
BCD tables only load in the browser
In Firefox 1.5, using this event handler in your page prevents the browser from caching the page in the in-memory bfcache. See Using Firefox 1.5 caching for details.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论