[whatwg] document.readyState and its initial value

Ian Hickson ian at hixie.ch
Mon Aug 4 23:29:06 PDT 2008


On Mon, 23 Jun 2008, Frode Børli wrote:
> 
> 1. Which readystate does an img object have, before it is added to the 
> DOM? Example:
> 
> var i = document.createElement("IMG");
> alert(i.readystate); // afaict the state SHOULD be uninitialized here...
> i.onreadystatechange(function(){alert(this.readystate);}
> i.src = "some_url.jpg";
> alert(i.readystate);

It seems only IE supports this property, so hopefully we don't need to 
spec it (or support it in other UAs).


> The example applies to iframes as well, i believe.

I couldn't reproduce this.


> 2. How can we listen to the onreadystatechange, if we want to trigger an 
> event when the object starts loading? It will not change readystate 
> since it was already in the state loading.

In HTML5 there's no way to get an event when an <img> begins loading. It 
begins loading when the src="" is set.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list