last week i came across a lovely snippet of code

 window.onbeforeunload = function(){ 
     return "what do you want to do?";
 }

This bit of code is what screams if you try to leave the site in any way, not just clicking on an outbound link or typing in the search/adress bar, but also if you hit the submit button on a form. The way to get around it is -

window.onbeforeunload = function(){ };

Apparently the return bit is very important for the onbeforeunload function to work.

Written with StackEdit.