How to prevent the user to change page with jQuery
<p>I have a page with a form that is submittes via ajaxSubmit() (so, without changing the page).</p>

<p>My goal is that, when the user try to change page (or even to close the browser), i ask him if really want to exit the page without sending the form (exactly as gmail does).</p>

<p>Gmail for example do this with a window.confirm-like popup, but if it is possible, i'll like to handle it with custom messages and options.</p>

<p>jQuery have the unload event:</p>

<pre><code>$(window).unload( function () { alert("Bye now!"); } );
</code></pre>

<p>but it permits me just to do something before exit the page; i need to 'block' the page exit, if the user click the relative button.</p>

<p>So, how to handle (and cancel) the page-exit event?</p>
