title: Leaving site javascript event - onbeforeunload - refresh page/internal hyperlink
body: <p>I'm trying the event onbeforeunload like below, it works fine when I close browser</p>
  
  <pre><code>    &lt;script type="text/javascript" language="javascript"&gt;
      window.onbeforeunload = LeavingSiteHandler;
      function LeavingSiteHandler(e) {
          if (!e) 
              e = window.event;
          //e.cancelBubble is supported by IE - this will kill the bubbling process.
          e.cancelBubble = true;
          e.returnValue = 'You sure you want to leave?'; //This is displayed on the dialog
  
          //e.stopPropagation works in Firefox.
          if (e.stopPropagation) {
              e.stopPropagation();
              e.preventDefault();
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>However, when I press F5 to refresh page or click on an internal link, this event will be fired. Is it possible to check whether the clicked hyper link is an internal link? Is it possible to stop this popup message in case I press F5?
  Thanks much!</p>