On Mar 11, 2011, at 7:41 AM, Bertilo Wennergren wrote:

Here's a limitation with "beforeunload" (in case someone hasn't

More of less the only thing you can do with "beforeunload", is to ask
the user if he or she really wants to leave the page. A dialog
will appear, and the user can choose to abort the unloading and stay
on the page. Normally you can add your own text to this dialog, informing why it might be wise not to leave the page. In Firefox 4 this is no longer possible! The dialog will have the following canned text that you cannot
change (it might be in another language though):

 "This page is asking you to confirm that you want to leave - data you
 have entered may not be saved."

That's what the dialog will say in Firefox 4. You can't change it, and you can't add anything to it. If the reason for using "beforeunload" does not have anything to do with entered data, or if you'd like to inform the user precisely what kind of data would be lost, or where on the page it is to be
found, or why it's would be so bad to lose it, you're out of luck.

This is all by design.

Bertilo Wennergren
berti...@gmail.com http://bertilow.com

Thanks, this is very interesting. I just tested with the following bit of code:

if (confirm('Are you sure you want to close the window?')) return true;

In Safari, I got what I expected -- my confirm dialog blocking the window close. But in Firefox 3.latest, I got two dialogs. First was my confirm, but when I okayed that I got the second, which was more or less exactly the same as what you describe for FF4. I commented out the confirm line, and got only the one alert, but then in Safari I got no warning at all.

I wonder if there's any way besides browser sniffing to work around this double-warning?


You received this message because you are subscribed to the Google Groups "Prototype 
& script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to