onunload 事件详细资料 SyntaxInline HTML <ELEMENT onunload = "handler" ... > All platforms Event property object.onunload = handler Microsoft?JScript?(compatible with ECMA 262 language specification) only object.onunload = GetRef("handler") Microsoft?Visual Basic?Scripting Edition (VBScript) 5.0 or later only Named script <SCRIPT FOR = object EVENT = onunload> Internet Explorer only Event Object InformationBubbles No Cancels No To invoke Close the current browser window. Navigate to another location by entering a new address or selecting a Favorite. Click the Back, Forward, Refresh, or Home button. Click on an anchor that refers the browser to another Web page. Invoke the anchor click method. Invoke the document write method. Invoke the document open method. Invoke the document close method. Invoke the window close method. Invoke the window open method, providing the possible value _self for the window name. Invoke the window navigate or NavigateAndFind method. Invoke the location replace method. Invoke the location reload method. Specify a new value for the location href property. Submit a FORM to the address specified in the ACTION attribute via the INPUT_submit control, or invoke the submit method.
Default action Removes the object or document from the browser window.
切换页面的时候不理睬,要关闭的时候才触发,怎么办?
SyntaxInline HTML <ELEMENT onunload = "handler" ... > All platforms
Event property object.onunload = handler Microsoft?JScript?(compatible with ECMA 262 language specification) only
object.onunload = GetRef("handler") Microsoft?Visual Basic?Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = object EVENT = onunload> Internet Explorer only Event Object InformationBubbles No
Cancels No
To invoke Close the current browser window.
Navigate to another location by entering a new address or selecting a Favorite.
Click the Back, Forward, Refresh, or Home button.
Click on an anchor that refers the browser to another Web page.
Invoke the anchor click method.
Invoke the document write method.
Invoke the document open method.
Invoke the document close method.
Invoke the window close method.
Invoke the window open method, providing the possible value _self for the window name.
Invoke the window navigate or NavigateAndFind method.
Invoke the location replace method.
Invoke the location reload method.
Specify a new value for the location href property.
Submit a FORM to the address specified in the ACTION attribute via the INPUT_submit control, or invoke the submit method.
Default action Removes the object or document from the browser window.
onbeforeunload
2. 关闭窗口对于第一步,系统以 onbeforeunload, onunload 通知页面脚本
对于第二步,系统根本就不打招呼!因此,对 javascript 来说,“关闭”与“离开”根本就是一回事,无法区分