onreadystatechange Event

MS Office DHTML, HTML & CSS

 
Click to return to the DHTML, HTML & CSS home page    
onpropertychange Event     onreset Event     DHTML Events    

onreadystatechange Event


Fires when the state of the object has changed.

Syntax

Inline HTML<ELEMENT onreadystatechange = "handler" ... >All platforms
Event propertyobject.onreadystatechange = handlerJScript (compatible with ECMA 262 language specification) only
Named script<SCRIPT FOR = object EVENT = onreadystatechange>Internet Explorer only

Remarks

BubblesNo
CancelsNo
To invoke Change the ready state.
Default action Signals the ready state of the document.

You can use the readyState property to query the current state of the element when the onreadystatechange event fires.

All elements expose an onreadystatechange event. The following objects always fire the event because they load data: APPLET, document, FRAME, FRAMESET, IFRAME, IMG, LINK, OBJECT, SCRIPT, and XML elements. Other objects will only fire the onreadystatechange event when a dhtml behaviorInternet Link is attached.

When working with behaviors, wait for the onreadystatechange event to fire and verify that the readyState property of the element is set to complete to ensure that the behavior is completely downloaded and applied to the element. Until the onreadystatechange event fires, if you use any of the behavior-defined members before attaching the behavior to the element, a scripting error can result, indicating that the object does not support that particular property or method.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties

srcElementRetrieves the object that fired the event.
typeRetrieves the event name from the event object.

Example

This example uses the onreadystatechange event to invoke a function when the readyState is complete.

document.onreadystatechange=fnStartInit;
function fnStartInit(){
   if(event.readyState=="complete"){
      // Finish initialization.
   }
}

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, custom, DD, DEL, DFN, DIR, DIV, DL, document, DT, EM, EMBED, FIELDSET, FONT, FORM, HEAD, Hn, HR, HTML, I, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, NEXTID, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XML, XMP

See Also

data bindingInternet Link, onload

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.