title: Is there a callback for cancelling window.onbeforeunload
body: <p>I don't have an actual use case for this, but I'm curious, whether there is a way to react (callback), if a user clicks on "stay on this page" when window.onbeforeunload was triggered.</p>
  
  <p><a href="http://jsfiddle.net/rWHU9/" rel="noreferrer">http://jsfiddle.net/rWHU9/</a></p>
  
  <pre><code>function warning(){
      if(true){
        console.log('leaving');
        return "You are leaving the page";
      }
  }
  window.onbeforeunload = warning;​
  </code></pre>