W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2008

[whatwg] salvaging work while navigating away from a web app -- onunload="confirm('save before quitting?')

From: Martin Atkins <mart@degeneration.co.uk>
Date: Fri, 12 Dec 2008 12:01:46 -0800
Message-ID: <4942C32A.9@degeneration.co.uk>
Bil Corry wrote:
> 
> Here's a fun one, I made this as a demo to show how a website could trap a user forever:
> 
> 	http://www.corry.biz/neverleave.lasso
> 
> I haven't tried it in any browsers lately, but a quick test with IE7 shows it still is effective (for it at least).
> 

I think this makes a good case for not allowing any site to create 
browser-modal UI. Could browsers handle confirm() and friends in such a 
way that they only block the contents of the tab, not the whole browser? 
In particular, the "close tab" and "close window" features, ideally 
along with things such as "Back", "Forward" and "Home" should still be 
available.

This does of course create some tricky interactions where onbeforeunload 
is concerned. If I try to close the browser/tab and the page uses 
onbeforeunload to create a confirmation prompt, how does this interact 
with the confirmation prompt only being tab-modal?

Here's a strawman (which I'm sure has some subtleties I've not 
considered): When the user navigates away from the page, fire 
onbeforeunload. However, if the user navigates away from the page WHILE 
THE ONBEFOREUNLOAD EVENT IS BEING HANDLED kill off the onbeforeunload 
handler and do whatever the user asked for.

A browser could potentially display some hard-coded (i.e. not 
site-overridable) UI here letting the user know that there's a page 
that's in the middle of "shutting down" and giving the option to kill it 
much like what happens when an application blocks Shutdown in Microsoft 
Windows. (though ideally without the confusing auto-timeout thing)
Received on Friday, 12 December 2008 12:01:46 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:46 UTC