Today, I have a shutdown event to listen to the capture browser , because I want to do something before I close it, considering that there are many ways to close the browser, such as: the top right corner x, the taskbar right close, the tab Check Point x , and so on. But at the moment I just need to put the top right corner x, tab Check point x operation to capture the control on the line.
For I have always liked to do background development, the front desk just slightly understand a little bit. Originally just do a page transformation, and later found that there is work to do, I had to bite the bullet dry, who called us a developer.
After a data query and testing, suddenly in front of the bright and cheerful, the problem solved. For IE browser through the onbeforeunload event can be a good capture control for Firefox FF browser through the onunload event capture control.
Now the code to share, hope that there is such a need for help, you can refer to.
//For IE browser through the onbeforeunload event can be a good capture control Window.onbeforeunload = function () {if (document.all) {var n = Window.event.screenx-window.screenleft; var b = n > document.documentelement.scrollwidth-20; if (b | | Window.event.clientY < 0 | | window.event.altKey) {//function invokes the method you want to process}}}//For Firefox Browser Control window via OnUnload event capture. OnUnload = function () {if (!document.all) {if (document.documentelement.scrollwidth==0) {//function invokes the method you want to process}}}