title: How can I prevent a page unload with jQuery?
body: <p>In my program, if a user tries to leave a page, he'll receive a dialog box asking if he is sure he wants to leave.</p>
  
  <p>How should I implement the 'cancel' option if the user chooses not to leave the page?</p>
  
  <p>Source javascript code:</p>
  
  <pre><code>$(window).unload(function(){
     var c= confirm ("Are you sure?");
     if (c){
         alert("Thanks. Good luck!");
     }
     else{
         ????
     }
  });
  </code></pre>