title: How to stop unloading the page?
body: <p>I have a page where user needs to enter some data and click save to validate the changes, but my problem is if the user is trying to close the browser window or click on a different link to navigate to a different page..I need to delete all the entries the user has saved so far..
  I am doing it the following way</p>
  
  <pre><code>window.onbeforeunload = function() 
  {
   if(confirm('Are you sure you want to navigate'))
    {
      //Invoke `enter code here`server side method
    }
   else
   {
     // return false;
   }
  }
  </code></pre>
  
  <p>Everything works fine if he click on Yes, the problem comes when he click on "No"..Even if he click on No..the page unload method is getting called and it is redirected to a different page..but I want it to stay in the same page in same state...can you please help me in achieving this.</p>
  
  <p>Thanks and appreciate your response....</p>