DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Detect Event Of Browser Close Button When [X] Is Clicked

12.21.2011
| 9742 views |
  • submit to reddit
        Some times we need to detect the Browser Close to perform some operation before quiting from application. Here is a simple way. 

Call this Method From Body Unload 
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');
    }
}


<a href="http://www.java-forums.org/blogs/spring-framework/"><strong>Spring Framework</strong></a>