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.
I have tried $(window).unload() in jQuery, but I can’t get it to work.
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.
Include the jQuery library in your code, and then try out this
JsFiddle Demo