title: Putting a condition on window.onbeforeunload
body: <p>I have this code:</p>
  
  <pre><code>window.onbeforeunload = (e) -&gt;
    e = e or window.event
    e.preventDefault = true
    e.cancelBubble = true
    e.returnValue = "You are not done yet with your Pleading Assembly."
    # if leave this page is click then
    #  notify
    return
  </code></pre>
  
  <p>And I don't know what line of code triggered the button "Leave this Page".</p>
  
  <p>Button "Leave this page" exist even I omit this</p>
  
  <pre><code>e.preventDefault = true
  e.cancelBubble = true
  </code></pre>
  
  <p>What I want to do is put a condition that if I click "Leave this page" Button, something will happen (in my part, I will notify a user)</p>
  
  <p>But unfortunately, I have no idea at all what should I do.</p>