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

SpecificationStatusComment
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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:59 次

字数:3601

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文