How to handle browser's window.onbeforeunload event
<p>I want to handle window.onbeforeunload event. I can handle it this way</p>

<pre><code>window.onbeforeunload = function() {
   return "MSG";
}
</code></pre>

<p>But in this case it shows a popup asking for user confirmation i dont want that confirmation dialog instead it will directly <code>return false</code> like <code>event.cancel = true</code>.</p>
