Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

How can i capture browser close event and tab close event in IE.


my requirement is like this.

we have a page and user cannot close the browser after load the data in to that page.

I need to prevent that browser close.Please help me.




Regards,
Shefeek
Posted

1 solution

XML
<script language="JavaScript" type="text/javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    return "You have attempted to leave this page.  If you have made any changes to the fields without clicking the Save button, your changes will be lost.  Are you sure you want to exit this page?";
  }
</script>
 
Share this answer
 
Comments
shefeekcm 20-Dec-12 0:16am    
i wish to work this only in browser close.How can i do this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900