title: How to detect the window(new tab) close event?
body: <p>I have one parent page and child page. the child page opened in new tab </p>
  
  <p>I want to show one alert message (The child page is closing)<strong>,</strong> when i close the child tab.<br>
  How to show the closing messgae, when close the tab? (Not refreshing time)</p>
  
  <p>I used <strong>onunload</strong>, and <strong>onbeforeunload</strong>.<br>
  Two methods are also called, when the page refresh and tab closing.   </p>
  
  <pre><code>window.onunload = function doUnload(e)
  {
    alert('Child window is closing...'); 
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>window.onbeforeunload = function doUnload(e)
  {
    alert('Child window is closing...'); 
  }
  </code></pre>
  
  <p>I must show the alert message, only <strong>close the tab</strong> in browser. </p>
  
  <p>Help me.
  Thanks in advance.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I use the following script. Its worked In IE. But not worked in FireFox</p>
  
  <pre><code>  &lt;script language="javascript" type="text/javascript"&gt;          
  
    window.onbeforeunload = function()
    {   
        if ((window.event.clientX &lt; 0) || (window.event.clientY &lt; 0) || (window.event.clientX &lt; -80)) 
       {            
            alert("Child window is closing...");  
       }   
   };   
  
  &lt;/script&gt;
  </code></pre>
  
  <p>How to acheive this in FireFox and other Browser.</p>