[whatwg] events when navigating away before page load?

Olli Pettay Olli.Pettay at helsinki.fi
Fri Dec 14 15:39:17 PST 2012


There are also pageshow and pagehide events,
although the spec for them seems to be wrong.
They are fired always, not only when dealing with session history.


-Olli



On 12/14/2012 08:51 PM, Mike Wilson wrote:
> 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