Re: Proposal: Detecting when the user leaves a page due to hitting the back button or typing in a URL or going to a favorite

2009/1/5 Boris Zbarsky <>

> Shropshire, Andrew A wrote:
>> 1. Allow the unload event to be cancellable from script.  This will
>> allow web designers to recreate the modal flavor of desktop apps like MS
>> Excel that prompt with "Yes/No Cancel" when there are unsaved changes.
> Doesn't the onbeforeunload event do this?  Or is your issue wanting to
> change the text and/or provide that one extra option (instead of the two
> dialogs one would need right now to give all three of Yes/No/Cancel as
> options)?  If so, would it make sense to extend onbeforeunload to do what
> you want instead of changing unload?

Probably treating the onbeforeunload as a real cancelable event (like
domactivate or rightclick) instead of callback that should provide some text
may be what he meant (the rest is matter of naming, ie. onunload vs

>  2. In the unload event, distinguish between closes and navigating away,
>> by adding a property to the event object such as getUnloadType() which
>> returns an enumerated type with one of these values:
> I'm not sure the script needs this information, to be honest.  What are the
> use cases?

One may attach a onbeforeunload to a frame, and would like to know if only
its javascript context is going to
disappear, instead of the whole tab being destroyed, so it can send messages
to parent window and have them read and handled


Received on Monday, 5 January 2009 16:18:24 UTC