Actually some browsers such as Google Chrome might block if you attempt to alert
in a window unload
. As a user I like this feature. Alerting every time you try to navigate away from a page sucks:
Replace the alert with a console.log
or something else less intrusive to the user and the event will be happily called.
You might also want to checkout the onbeforeunload event.