title: Determine the close button click of Browser, refresh and going to new page
body: <p>i have to clear session and delete some data from my database on browser close/refresh/location change</p>
  
  <p>i need a code which could do something like this</p>
  
  <pre><code>$('cross button,refresh').click(function()
  {
      preventdefault();
      // call my delete script
      $(browser).close();
  });
  </code></pre>