How can I detect when the user is leaving my site, not just going to a different page?
<p>I have a handler for onbeforeunload</p>

<pre><code>window.onbeforeunload = unloadMess;
function unloadMess(){
  var conf = confirm("Wait! Before you go, please share your stories or experiences on the message forum.");
    if(conf){
    window.location.href = "http://www.domain.com/message-forum";
    }
}
</code></pre>

<p>but I'm not sure how to know if the url they clicked on the page is within the site.</p>

<p>I just want them to alert them if they will leave the site.</p>
