Introduction
This article will describe how we can detect the browser when user click on the Close [X] button .
When we need this ?
There are some scenarios where this can be apply - We have log off button on web site, and on logoff we are removing some database information of that user and clearing the session. But unfortunately user Click on [X] button . So, what will happen . we can apply this code on that situation.
- We have to give some Message if user Click [X ] button of the browser
Code
{codecitation class="brush: javascript; gutter: true;" width="650px"}
function DeleteLog() { // 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'); } }
{/codecitation}
Description : Call this code from the Body Unload of the form. I have opened an window which will open in a differnt location that you can guess from the left and top position of the popup window. Do what ever function you want to perform on the server side of that popup and the close that popup by using Self.Close() Hope this will help you. Thank you Jana |