title: override browser back button
body: <p>I am working on a project in which i need to handle browser back button and on it's click I want to redirect to home page.</p>
  
  <p>I have gone through many post, there are a lot of ways to implement it.</p>
  
  <p>I am wondering, what is the best way to implement it.</p>
  
  <p>If anyone knows similar post, please post the url.</p>
  
  <p>Thanks for help</p>
  
  <p>I have used the following codes:</p>
  
  <pre><code>function HandleBackFunctionality()
  {
      alert('ckikc')
      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
      {
          alert('clicked')
          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...");
          }
      }
  }
  window.onbeforeunload = HandleBackFunctionality;
  $(document).unload(HandleBackFunctionality);
  </code></pre>
  
  <p>well its not working for me :(</p>
  
  <p>well @kapa said it is a duplicate question, I have mentioned that have googled a lot for this and have seen a lot of solutions for this problem.</p>
  
  <p>my question is not the way to solve it, but the best solution out of available one</p>