The readyState Property


The readyState Property

The readyState property gives you some indication of the progress of an object loading its data. For example, an <IMG> element might take some time to load an image, and you can use this property to check when it's done. You can see the support for this property in Table 5.46.

Table 5.46. The readyState Property

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

readyState

           

x

x

x

x

 

Read-only

 

Type: String

The possible strings returned, such as "complete" or "loaded" appear in Table 5.47. (The <OBJECT> element returns numbers rather than strings, and those numbers are also listed in Table 5.47.)

Table 5.47. The readyState Property Values

Value

Means

complete

All data is loaded ( <OBJECT> value: 4).

interactive

Not all data is loaded, but the object can interact with the user ( <OBJECT> value: 3).

loaded

All data is loadedbut object may be busy working on that data ( <OBJECT> value: 2).

loading

Data is still being loaded ( <OBJECT> value: 1).

For example, you can check the readyState property of an image named image1 like this: document.all.image1.readyState . Although Internet Explorer 4.0 supported this property for only a few elements (such as <IMG> , <OBJECT> , and <EMBED> ), starting with Internet Explorer 5.0 you can use this property on nearly every element.

TIP

You can't use the readyState property to check whether an element itself is loaded, just whether its data is loadedthe element itself needs to be present before you can even use the readyState property.




Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net