title: detecting browser back button in javascript/jquery without using any external plugins
body: <p>I want to detect browser back button in java-script/jquery without using any external plugins.</p>
  
  <p>I am going to support following browsers</p>
  
  <p><strong>IE8,IE9,FireFox,Chrome</strong></p>
  
  <p>I googled so many links and found below part of code from code project </p>
  
  <pre><code>&lt;body onbeforeunload=”HandleBackFunctionality()”&gt;
  
  function HandleBackFunctionality()
  {
      if(window.event)
     {
          if(window.event.clientX &lt; 40 &amp;&amp; window.event.clientY &lt; 0)
          {
              alert("Browser back button is clicked...");
          }
          else
          {
              alert("Browser refresh button is clicked...");
          }
      }
      else
      {
          if(event.currentTarget.performance.navigation.type == 1)
          {
               alert("Browser refresh button is clicked...");
          }
          if(event.currentTarget.performance.navigation.type == 2)
          {
               alert("Browser back button is clicked...");
          }
      }
  }
  </code></pre>
  
  <p>The above code working fine IE browser. that means i can able to get the window.event.clientX and clientY values in IE browser. but in chrome/firefox not working.</p>
  
  <p>When browser back button is clicked, i need to refresh the page.</p>
  
  <p>how can i detect browser back button click event in all browsers (IE,firefox,chrome)</p>
  
  <p>any help would be appreciated.</p>