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

Bil Corry bil at corry.biz
Fri Dec 12 11:17:39 PST 2008

Ojan Vafai wrote on 12/12/2008 12:49 PM: 
> If we're going for matching what browsers do, there's a number of cases
> (different in each browser) where the confirm doesn't popup. In Chrome, for
> example, if the beforeunload handler takes too long, we kill it and navigate
> away. Similarly, in Firefox, if the beforeunload handler hits the limit for
> script execution and the user stops the script, the beforeunload handler
> never fires.
> Not sure what the right language for that is. But developers try to do
> things like using beforeunload/unload to release locks, make server
> requests, etc. and it's just not a very reliable thing to do in any browser.
> It's really just useful for the quick prompt for the user as to things like
> unsaved changes.

Here's a fun one, I made this as a demo to show how a website could trap a user forever:


I haven't tried it in any browsers lately, but a quick test with IE7 shows it still is effective (for it at least).

- Bil

More information about the whatwg mailing list