Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

我們的志工尚未將此文章翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!

Summary

The unload event is raised when the window is unloading its content and resources. The resources removal is processed after the unload event occurs.

Syntax

window.onunload = funcRef;
  • funcRef is a reference to a function.

Notes

Using this event handler in your page prevents Firefox 1.5 from caching the page in the in-memory bfcache. See Using Firefox 1.5 caching for details.

Browsers equipped with pop-up window blockers will ignore all window.open() method calls in onunload event handler functions.

You can and should handle this event through window.addEventListener() and the unload event. More documentation is available there.

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'GlobalEventHandlers' in that specification.
Living Standard  
HTML5.1
The definition of 'GlobalEventHandlers' in that specification.
Working Draft  
HTML5
The definition of 'GlobalEventHandlers' in that specification.
Recommendation  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)

文件標籤與貢獻者

 最近更新: teoli,