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

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