[whatwg] When closing the browser

David,

The onbeforeunload event handler can be used in this manner. See these posts:

http://www.nczonline.net/archive/2006/3/311
http://www.nczonline.net/archive/2006/3/312

-Nicholas




?
I made a quick look through the HTML 5 Working Draft table of contents, as well as Anne's "differences" document and went looking through http://www.w3.org/html/wg/html5/#processing2?the changes on the network and processing models to see if this was covered or not, but didn't see it. I probably missed it, but noticed something today that I was fooling around with some years ago and wondered if it has been addressed.
?
The user opens a web application as one of many tabs in a web browser. They then, either within the application window, accidentally hit CTRL W (or its Mac equivalent), or from the operating system, issue a close application command. Most apps (as opposed to the more "passive" browsers) detect that new content has been developed and in is jeopardy of being lost and therefore prompt the user to the status of this possible data loss. The browser, unless I'm missing something, seems to have a different status within the OS and just closes without ceremony.
?
The way I've handled this is the past is to have an onunload script associated with the body: onunload="if (confirm('Save before quitting')) (SaveIt());" where SaveIt is some magic function which writes to disk (I understand that such a technique will standardize writing to local drive space in HTML5). I also understand that there will be ways of overriding the default definitions of CTRL-W etc. so that the developer may change these unpleasantries inherited from the browser. However, in the case of the solution using onload/confirm, (if you're not averse to using IE and looking at VML then see http://srufaculty.sru.edu/david.dailey/grapher/grapher.96.html?for an example) , you have two choices: save and cancel -- "cancel" terminates without saving, "save" terminates after saving.
?
Has this group or HTMLWG?yet decided on a way of preventing accidental loss of work for web applications in a way?similar to?how "applications" handle the situation?
?
cheers,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20080228/ce32948b/attachment.htm>

Received on Thursday, 28 February 2008 14:59:34 UTC