I have this simple piece of code -
$(window).bind(\'beforeunload\', function(){
alert(\"Good Bye\")
});
Works great with Firefox, IE8 but
Try this:
function LogTime(){
jQuery.ajax({
type: "POST",
url: "log.php",
data: "",
cache: false,
success: function(response){
}
});
}
$(window).bind('beforeunload', function(){
LogTime();
return "You're leaving?";
});
It seems that as long as you return a string for this event at the end of function body, you can run code before that string.