readystatechange

  • Revision slug: DOM/Mozilla_event_reference/readystatechange
  • Revision title: readystatechange
  • Revision id: 366035
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment Moved From Mozilla_event_reference/readystatechange to DOM/Mozilla_event_reference/readystatechange

Revision Content

The readystatechange event is fired when the readyState attribute of a document has changed.

General info

Specification
HTML5
Interface
Event
Bubbles
No
Cancelable
No
Target
Document
Default Action
None.

Properties

{{OpenEventProperties()}}{{CloseEventProperties()}}

Example

// alternative to DOMContentLoaded
document.onreadystatechange = function () {
    if (document.readyState == "complete") {
        initApplication();
    }
}

Browser compatibility

This event has long been supported by Internet Explorer and can be used as an alternative to the DOMContentLoaded event (see the cross-browser fallback section).

{{LoadRelatedEvents()}}

Revision Source

<p>The <code>readystatechange</code> event is fired when the <a href="/en-US/docs/DOM/document.readyState"><code>readyState</code></a> attribute of a document has changed.</p>
<h2 id="General_info">General info</h2>
<dl>
  <dt style="float: left; text-align: right; width: 120px;">
    Specification</dt>
  <dd style="margin: 0 0 0 120px;">
    <a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness">HTML5</a></dd>
  <dt style="float: left; text-align: right; width: 120px;">
    Interface</dt>
  <dd style="margin: 0 0 0 120px;">
    Event</dd>
  <dt style="float: left; text-align: right; width: 120px;">
    Bubbles</dt>
  <dd style="margin: 0 0 0 120px;">
    No</dd>
  <dt style="float: left; text-align: right; width: 120px;">
    Cancelable</dt>
  <dd style="margin: 0 0 0 120px;">
    No</dd>
  <dt style="float: left; text-align: right; width: 120px;">
    Target</dt>
  <dd style="margin: 0 0 0 120px;">
    Document</dd>
  <dt style="float: left; text-align: right; width: 120px;">
    Default Action</dt>
  <dd style="margin: 0 0 0 120px;">
    None.</dd>
</dl>
<h2 id="Properties">Properties</h2>
<p>{{OpenEventProperties()}}{{CloseEventProperties()}}</p>
<h2>Example</h2>
<pre class="brush: js">
// alternative to DOMContentLoaded
document.onreadystatechange = function () {
    if (document.readyState == "complete") {
        initApplication();
    }
}
</pre>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>This event has long been supported by Internet Explorer and can be used as an alternative to the <a href="/en-US/docs/Mozilla_event_reference/DOMContentLoaded_(event)"><code>DOMContentLoaded</code></a> event (see the <a href="/en-US/docs/Mozilla_event_reference/DOMContentLoaded_%28event%29#Cross-browser_fallback">cross-browser fallback</a> section).</p>
<h2 id="Related_Events">Related Events</h2>
<p>{{LoadRelatedEvents()}}</p>
Revert to this revision