W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2008

Need onBeforeUnload event handler for HTML Window object

From: Shropshire, Andrew A <shropshire@att.com>
Date: Tue, 30 Dec 2008 12:04:16 -0500
Message-ID: <24D5F2204CBFC84499520C14CC11036C0823ABAE@vna-exch1.gsi.grci.com>
To: <public-webapps@w3.org>
Cc: "Hallquist, Steig" <steig.hallquist@att.com>, "Rodrigues, Larry E" <lerodrigues@att.com>
To Web Apps Working Group,

 

I do web application development work for the government and there are
often many forms to fill out online.  It would be nice if there were
some way to warn the user if they did not save their form entries prior
to navigating away (by using the browser back button, entering a new
URL, etc), and allow them to cancel the page unload.

 

Microsoft has implemented an onBeforeUnload event to address this issue
(http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx).

 

Please address this issue in the DOM Level 3 Events standard.  The
onBeforeUnload is fine, but not the message text that the programmer
cannot alter  "Are you sure you want to navigate away from this page?
.... Press OK to continue, or Cancel to stay on the current page.".  

 

Alternatively, some means could be provided to cancel the onload event.

 

Thanks for your consideration of this matter.

 

Andrew Shropshire

From: Shropshire, Andrew A 
Sent: Tuesday, December 30, 2008 10:02 AM
To: Hallquist, Steig; Rodrigues, Larry E
Subject: RE: CR From shaffer

 

Yes.  The present standard covering events is

 

http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/

 

If you look at the HTML events section:

 

http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Ev
ents-eventgroupings-htmlevents

 

There is an unload event but no beforeunload event.

 

I don't see it in the DOM 3 Events draft either.  There is a working
group chartered for that (see
http://www.w3.org/2008/webapps/wiki/Main_Page).  

 

The solution I sent earlier has an unload handler which works too,
however, it causes the page to be refreshed.

 

From: Hallquist, Steig 
Sent: Tuesday, December 30, 2008 8:40 AM
To: Shropshire, Andrew A; Rodrigues, Larry E
Subject: RE: CR From shaffer

 

Is this an IE specific solution?  How much has been built into
CIVFORS/WASS that is specific to the browser?

 

________________________________

From: Shropshire, Andrew A 
Sent: Tuesday, December 30, 2008 6:24 AM
To: Hallquist, Steig; Rodrigues, Larry E
Subject: RE: CR From shaffer

 

Yes,  note that the problem involves detecting not only back button
presses, but also going to a favorite link or to a URL that the user
manually types in.  The IE browser has an event handler for this
situation:  onbeforeunload.  Attached is an example page with this
feature.  The function is a bit of a hack and has some unusual quirks,
but it should work for the situation below.

 

From: Hallquist, Steig 
Sent: Monday, December 29, 2008 3:00 PM
To: Shropshire, Andrew A; Rodrigues, Larry E
Subject: CR From shaffer

 

Here's a WAF Change request entered by Rich: If you navigate away from
an edit page, you should receive a warning that you may

lose information.

 

Is it possible to warn someone if they use the browser back buttons
prior to navigating away?  If so how much work is involved?

 

Steig Hallquist

CIVFORS Project Manager

AT&T Government Solutions, Inc.

703-506-5395

 
Received on Wednesday, 31 December 2008 05:13:40 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:29 GMT