[whatwg] When closing the browser

Bil Corry bil at corry.biz
Fri Dec 12 06:59:49 PST 2008


Ian Hickson wrote on 12/12/2008 2:50 AM: 
> On Thu, 28 Feb 2008, ddailey wrote:
>> 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.
> 
> I just went ahead and specced out the 'onbeforeunload' feature that most 
> browsers support today that handles this case.


Speaking of 'onbeforeunload' and 'beforeunload' -- it'd be helpful if there was a way to distinguish between the user taking an action which leaves the site vs. taking an action that returns to the site.  E.g.:

	leaves site:
		closes browser
		closes tab
		closes window
		back/forward to different site
		GET/POST to another site
		navigates away using address bar

	returns to site:
		reloads page
		back/forward to same site
		GET/POST to same site


For privacy, it shouldn't reveal which specific action triggered the event, but knowing if the user is leaving the site means webapps can finally auto-logout the user, which in turn greatly improves security.


- Bil 




More information about the whatwg mailing list