window.onunload = function()
{
confirm("close the window?")
}
Why don't I have the confirm window coming out when closing a window?
window.onunload = function()
{
confirm("close the window?")
}
Why don't I have the confirm window coming out when closing a window?
Presumably it is to prevent pages from repeatedly preventing you from closing a page. With the beforeunload
event, you can, however, get what is, in most modern browsers, a non-customizable or only partly customizable dialog prompting the user whether to leave or not.
Many browsers not support window.unload.
Please view this link.
window.onbeforeunload and window.onunload is not working in Firefox , Safari , Opera?
Most browsers prevent the use of alert/confirm in onunload. Instead use an onbeforeunload handler that returns a string:
window.onbeforeunload = function() {
return "Don't go!";
};
This will then be presented to the user in a dialogue box.
See also: window.unload() won't work in jQuery