Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

document.readyState

概述

document文档正在加载时,返回"loading"。当文档结束渲染但在加载内嵌资源时,返回"interactive",并引发DOMContentLoaded事件。当文档加载完成时,返回"complete",并引发load事件。

readystatechange事件会在document对象上的readyState属性的属性值发生变化时触发.

语法

var string = document.readyState;

例子

// 模拟DOMContentLoaded
document.onreadystatechange = function () {
  if (document.readyState == "interactive") {
    initApplication();
  }
}
// 模拟 load事件
document.onreadystatechange = function () {
  if (document.readyState == "complete") {
    initApplication();
  }
}

相关链接

规范

文档标签和贡献者

 此页面的贡献者: gqqnbig, teoli, szmtcjm, khalid32, ziyunfei
 最后编辑者: gqqnbig,