[whatwg] events when navigating away before page load?

Mike Wilson mikewse at hotmail.com
Fri Dec 14 10:51:49 PST 2012


Thanks Ian, 

Ian Hickson wrote on 14 december 2012 19:22:
> On Fri, 14 Dec 2012, Mike Wilson wrote:
> >
> > What events are supposed to be fired when the browsing context 
> > gets navigated away before the current page has finished 
> > loading, ie before the load event has been fired?
> 
> It's pretty complicated, but the short answer is "beforeunload" 
> and "unload". "DOMContentLoaded" and "load" don't fire per spec, 
> though this is controversial (it's been suggested that the abort
> that happens during navigation should be equivalent to the abort 
> that happens when the user hits "Stop"; whether it is or not 
> changes whether or not we pretend that the page finished parsing 
> or not).

I added the beforeunload event in an updated fiddle:
http://jsfiddle.net/khwtB/

which resulted in:

              FF17  Chr23 IE9   spec
              ----- ----- ----- -----
domload       y     y     n     n
load          n     n     n     n
beforeunload  y     n     y     y
unload​       y     y     n     y

So yes, it seems there is a lack of agreement here :-)

Anyway, the finding that originally got me started on looking at
this was that I received an unload event without a preceeding
load event. Naively this seems logically wrong, but I appreciate
these are complicated matters so I'm content with the answer that
this probably shouldn't be expected in these kinds of cases.

Best regards
Mike




More information about the whatwg mailing list