This code runs fine on Firefox, but I can\'t make the unload event work on Chrome anymore. Did Chrome stop supporting the unload event?
This is my c
window.onunload = alert("Are you sure 2?");
This is incorrect. You are setting onunload to the result of alert, you need to set it to a function:
window.onunload = function(){
alert("Are you sure?");
}
If you want to use jQuery, this will work in all browsers.
$(window).unload(function () {
alert("Are you sure?");
});
NOTE: It might seem like it's not working in Chrome, but it is. That's because Chrome blocks alerts in the onunload event.