W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2012

Re: load event after window.location.replace ?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 31 May 2012 23:39:36 -0400
Message-ID: <4FC83978.8000409@mit.edu>
To: www-dom@w3.org
On 5/31/12 10:51 PM, David Karger wrote:
> The working draft is unclear on the following question: if
> window.location.replace() is invoked, should a "load" event fire when
> the new content arrives?

Yes, it should.

> A quick test
> (http://people.csail.mit.edu/karger/Scrapelet/Dev/testload.html)
> demonstrates that current browsers do *not* fire a load event for the
> replaced content.

Sure they do.  But they're firing it at the new window object that's 
created for the new page, while your event listener is registered on the 
window object for the page being unloaded...

There's a special hack in place for the case when the page being 
unloaded is the initial about:blank that makes the browser reuse the 
window in some cases, which is why the outer DOMContentLoaded in your 
testcase works.

> If that is correct, then how are we supposed to detect
> that the replaced content has finished loading?

Right now, you can't really tell, unless you're replacing something in 
an iframe (in which case you get a load event on the <iframe> element).

-Boris
Received on Friday, 1 June 2012 03:40:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:09 GMT