title: Ask whether the user is sure to leave the site (XHTML/JavaScript)
body: <p>When a user leaves one page of my website, there should be a warning message which gives the user the option to stay on the page:</p>
  
  <p>"Are you sure that you want to close this page?"</p>
  
  <p>It doesn't matter if the next page is an internal or external page.</p>
  
  <p>I thought this could be done with the onUnload event handler, couldn't it?</p>
  
  <pre><code>&lt;body onunload="confirmClose()"&gt;
  </code></pre>
  
  <p>The confirmClose() function must then show a message box with two buttons so that the user can choose between "Really leave" or "Stay".</p>
  
  <pre><code>function confirmClose() {
      return confirm('Really leave this page?')
  }
  </code></pre>
  
  <p>But this function can't stop the unload, right?</p>
  
  <p>Do you have a solution for my problem? Thanks in advance!</p>