On Mar 11, 2011, at 7:50 PM, joe t. wrote:

Here's a sample from code that i wrote and seems to work ok (at least,
last i tested it, i no longer work there), adapted for generics:

So here's what i learned, now that my curiosity got roused...

The beforeunload event will automatically generate the prompt. If you
want to inject a custom message into that prompt (not speaking for
FF4, as i haven't tested on that with my prior code), you assign that
STRING to the event.returnValue property.

i'm pretty sure that by assigning a value to event.returnValue, the
prompt is fired. If it has no value by the time the handler returns,
the prompt does not occur.

The user is prompted with the built-in prompt, plus your custom

The event will automatically cancel ITSELF if the user hits the Cancel
button of the confirmation message.

There's no need to put a confirm in the event handler yourself. That's
what would cause the double-prompt, and the confirm you generate is
ignored by the event anyway.

That's the best i can recall, anyway. i hope it helps.
-joe t.

This works really nicely in Firefox 3.latest, and does what you say -- intermingles the custom message with the browser default message. But in Safari 5.latest, closing the window does nothing -- no alert of any kind is issued. That's why I ended up putting the confirm() in there in the first place -- to get Safari to do something in this event.


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