Link to home
Start Free TrialLog in
Avatar of sanrich
sanrich

asked on

javascript on browser close button

Hi,

I got one javascript which is solving my issue but I need your help to make it completly working. In the enclosed javascript when I click browser close button then popup is appearing fine. It provides me two option "ok" and "cancel". When I click "ok" button then it is not showing me alert.
 alert("Window is closed");
Can you please help. I am enclosing code

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD>  <TITLE> Window Close Test </TITLE>  <META NAME="Generator" CONTENT="EditPlus">  <META NAME="Author" CONTENT="">  <META NAME="Keywords" CONTENT="">  <META NAME="Description" CONTENT="">  
  <script type="text/javascript">
 var myclose = false;
 function ConfirmClose(){
 if (event.clientY < 0)
 {
 event.returnValue = 'Any message you want';      
 setTimeout('myclose=false',100);
 myclose=true;            
 }
 }
 function HandleOnClose()      {
 if (myclose==true)      {
 alert("Window is closed");
 //you can write your specific code here to call action            
 }
 }
 </script>
 </HEAD>
 <BODY>
 <body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()">
 <input type="submit" name="add" id="add" value=" ADD " tabindex="19" />&nbsp;&nbsp; &nbsp;
 <input type="submit" name="edit" id="edit" value=" EDIT " tabindex="20" />&nbsp;&nbsp; &nbsp;
 <input type="submit" name="delete" id="delete" value="DELETE" tabindex="21" />&nbsp;&nbsp;&nbsp;&nbsp;  
 </BODY></HTML>  
ASKER CERTIFIED SOLUTION
Avatar of Pawel Witkowski
Pawel Witkowski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.