Detect when user navigates away from page
<p>How do I detect that a user is navigating away from my page?
Kind of like stackoverflow does, if you have started writing a post.</p>

<p>I have tried <code>$(window).unload()</code> in jQuery, but I can't get it to work.</p>

<p>This statement is not entirely true, in IE9 it works, in fact a bit too well. It also pops up, if the page is refreshed.
But in Chrome, nothing triggers.</p>
