title: How to detect a window close event using javascript or php
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3888902/javascript-detect-browser-close-tab-close-browser">javascript detect browser close tab/close browser</a>  </p>
  </blockquote>
  
  
  
  <p>I am doing a real time game site in php, I wish to call a function on closing the browser, how can i detect closing the browser using php or javascript ? I have tried using onbeforeunload and onunload events, but found that these events are triggered even if the window is refreshed or navigates using back button, forward button etc.. And also these events are not working well in all popular browsers. Is there any posible way to detect only the window close event which performs well in all browsers? </p>
  
  <p>Thanks in advance </p>