Guest User

Guest User

  • Tech Writer
  • 43
  • 62.8k

When Customer Close the window Open another Window

Mar 6 2012 8:34 AM
Hi ,
When Customer close or exit the browser i want to open another popup window by using onbeforeunload event the below code that working fine . but my query is when am refreshing the page that time also onbeforeunload event firing.please help me how to solve the problem. Thanks in advance.

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
   window.onbeforeunload=function(){
  if((window.event.clientX<0) || (window.event.clientY<0))
    {
    alert("Closing Browser!!!");
      window.open("http://www.google.com");
      }
    else
    {
        alert("You are not Closing the Browser");  
    }
  }
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   <asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" />
        </div>
    </form>
</body>
</html>

Please help me Thanks in Advance ....





Answers (3)