Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to detect browser close when browser [X] is clicked ?

0.00/5 (No votes)
2 Sep 2009 1  
Some times we need to detect the Browser Close to perform some operation before quiting from application. Here is a simple way.function CheckBrowser(){ // Check Browser Close [X] , Alt+F4 , File -> Close if(window.event.clientX < 0 && window.event.clientY <0) { wi
Some times we need to detect the Browser Close to perform some operation before quiting from application. Here is a simple way.
function CheckBrowser()
{
     // Check Browser Close [X] , Alt+F4 , File -> Close  
     if(window.event.clientX < 0 && window.event.clientY <0)
    {
          window.open("Operation.aspx", 
                "Operation",'left=12000,top=1200,width=10,height=1');
    }
}
Call this Method From Body Unload

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here