How to warn user not to leave the page?
<blockquote>
  <p><strong>Possible Duplicates:</strong><br>
  <a href="http://stackoverflow.com/questions/3998603/how-can-i-ask-a-web-user-for-confirmation-if-he-really-wants-to-leave-the-page">How can I ask a web user for confirmation if he really wants to leave the page?</a><br>
  <a href="http://stackoverflow.com/questions/140460/client-js-framework-for-unsaved-data-protection">Client/JS Framework for &ldquo;Unsaved Data&rdquo; Protection?</a>  </p>
</blockquote>



<p>Like stackoverflow does on the ask page, when I click the close button or any other link on the site a dialog pops up asking if you're sure you want to navigate away from the page. How to do that in javascript or jQuery and can you customize the text in the box?</p>
