Onunload,onbeforeunload is called when the page is refreshed or closed, except that:
onBeforeUnload is triggered before the page is refreshed or closed, and the browser does not request the server to read the new page, so onbeforeunload can prevent the page from being updated or closed.
OnUnload is also triggered when the page is refreshed or closed, but the browser has asked the server to read the new page, so onunload cannot prevent the page from being updated or closed.
1. The onbeforeunload Incident
When an event is triggered, a confirmation and Cancellation dialog box pops up to confirm that the subsequent events will not be performed or remain on this page.
Trigger on:
Close browser window
When you go to another page by using the Address bar or favorite folder
Click Back, Forward, refresh, homepage one of the time
Click on a URL to another page to connect
When you invoke any of the following events: Click,document write,document open,document close,window Close, window navigate, window Navigateandfind, Location Replace,location Reload,form Submit.
When you open a page with window open and pass the name of the window of this page to the page you want to open.
When the value of the LOCATION.HREF is again assigned.
Submit a form with the specified action through the input type= "submit" button.
Can be used in the following elements:
Body, FRAMESET, window
Platform support: Ie,firefox,chrome,safari. Opera does not support the temporary.
Example:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
2. The OnUnload incident
When an event is triggered, a confirmation dialog box pops up and the point is determined to perform subsequent events.
Trigger on:
Close browser window
When you go to another page by using the Address bar or favorite folder
Click Back, Forward, refresh, homepage one of the time
Click on a URL to another page to connect
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/
When you invoke any of the following events: Click,document write,document open,document close,window Close, window navigate, window Navigateandfind, Location Replace,location Reload,form Submit.
When you open a page with window open and pass the name of the window of this page to the page you want to open.
When the value of the LOCATION.HREF is again assigned.
Submit a form with the specified action through the input type= "submit" button.
Platform support: Only IE, no other support.
Example:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Author: csdn blog proud Snow star Maple