Re: Javascript events
Apparently, the only event (as I'm quiet aware) that would help you in your desire is the "onbeforeunload" which runs when your user is trying to leave your page.
Unluckily, an odd dialog will be seen (as what you might have exprerience).