I have this simple piece of code -
$(window).bind(\'beforeunload\', function(){ alert(\"Good Bye\") });
Works great with Firefox, IE8 but
Try this for all Browsers:-
window.addEventListener("beforeunload", function (e) { var confirmationMessage = "\o/"; e.returnValue = confirmationMessage; return confirmationMessage; });