document.onreadystatechange

  • Revision slug: DOM/document.onreadystatechange
  • Revision title: document.onreadystatechange
  • Revision id: 293356
  • Created:
  • Creator: louisremi
  • Is current revision? No
  • Comment

Revision Content

{{ DomRef() }}

{{ gecko_minversion_header("2.0") }}

Summary

the readystatechange event is fired when document.readyState is changed.

Syntax

document.onreadystatechange = funcRef;

funcRef is a function reference, called when the event is fired.

Example

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

See Also

Specification

{{ languages( { "zh-cn": "zh-cn/DOM/document.onreadystatechange" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<p>{{ gecko_minversion_header("2.0") }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>the <strong>readystatechange</strong> event is fired when <code>document.readyState</code> is changed.</p>
<h3 class="editable" id="Syntax_"><span>Syntax </span></h3>
<pre class="eval">
<em>document.onreadystatechange = funcRef;</em>
</pre>
<p><em>funcRef</em> is a function reference, called when the event is fired.</p>
<h3 class="editable" id="Example"><span>Example</span></h3>
<pre class="brush: js">
// alternative to DOMContentLoaded
document.onreadystatechange = function () {
    if (document.readyState == "complete") {
        initApplication();
    }
}
</pre>
<h3 class="editable" id="See_Also">See Also</h3>
<ul>
  <li><a class="internal" href="/en/DOM/document.readyState" title="en/DOM/document.readyState">document.readyState</a></li>
</ul>
<h3 class="editable" id="Specification_"><span>Specification </span></h3>
<ul>
  <li><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness" title="http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness">http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness</a></li>
</ul>
<p>{{ languages( { "zh-cn": "zh-cn/DOM/document.onreadystatechange" } ) }}</p>
Revert to this revision