65.9K
CodeProject is changing. Read more.
Home

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

Aug 26, 2009

CPOL
viewsIcon

66673

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