onreadystatechange event

Fires when the state of the object has changed.


HTML Attribute <element onreadystatechange = "handler(event)">
Event Property object.onreadystatechange = handler;
attachEvent Method object.attachEvent("onreadystatechange", handler)
addEventListener Method object.addEventListener("readystatechange", handler, useCapture)

Event information

Synchronous No
Bubbles No
Cancelable No

Event handler parameters

  • pEvtObj [in]
    Type: [IHTMLEventObj](aa703876(v=vs.85).md)

Standards information

There are no standards that apply here.


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

All elements expose an HTMLAnchorEvents2::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 HTMLAnchorEvents2::onreadystatechange event when a DHTML Behavior is attached.

Note For the script element, HTMLAnchorEvents2::onreadystatechange is no longer supported. Starting with Internet Explorer 11, use HTMLFrameSiteEvents::onload. For info, see Compatibility changes.

When working with behaviors, wait for the HTMLAnchorEvents2::onreadystatechange event to fire and verify that the IHTMLLinkElement::readyState property of the element is set to complete to ensure that the behavior is completely downloaded and applied to the element. Until the HTMLAnchorEvents2::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.

Signals the ready state of the document.

To invoke this event, do one of the following:

  • Change the ready state.

The pEvtObj parameter is required for the following interfaces:

See also




Introduction to Data Binding