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

Thanks everyone for addressing this issue.  The wiki page does help
underscore the need for something like onbeforeunload in the standard.

Whether onbeforeunload is fixed or whether to change unonload seems not
too important since the functionality offered by either approach is
identical.  Having a separate onbeforeunload seemed to me to
unnecessarily complicate matters.
 
I am working a dialog problem now and I have discovered another problem
with Onbeforeunload:

It is called even for javascript URLs which clearly aren't exiting the
page.  Ie.  It gets called when user clicks on <a
href="javascript:doSomeFunction()">Link</a>

This is very annoying, as I must change this to
<span style="cursor:pointer;text-decoration:underline"
onclick="doSomeFunction();">Link</span>
To avoid this.

Andrew


-----Original Message-----
From: Mike Wilson [mailto:mikewse@hotmail.com] 
Sent: Monday, January 05, 2009 11:53 AM
To: 'Boris Zbarsky'; Shropshire, Andrew A
Cc: public-webapps@w3.org
Subject: 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

Boris Zbarsky wrote:
> 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?

Yes, that's the way I would go. I've also wanted to be able to 
customize the onbeforeunload dialog in some projects. 

There's some write-up here:
http://www.openajax.org/runtime/wiki/Enhanced_support_for_dialogs

Care must be taken though to ensure there is always a way to 
continue even if a custom dialog in an evil page "removes" the 
Continue option.

Best regards
Mike Wilson

Received on Monday, 5 January 2009 18:59:21 UTC