在DOMContentLoaded上的document.readyState? [英] document.readyState on DOMContentLoaded?

查看:130
本文介绍了在DOMContentLoaded上的document.readyState?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在支持事件 DOMContentLoaded 和属性 document.readyState 的浏览器中:

In browsers that support the event DOMContentLoaded and the property document.readyState:


DOMContentLoaded 触发时,我可以假设 document.readyState 将永远是完成interactive / 加载

When DOMContentLoaded fires, can I assume that the value of document.readyState will always be either "complete" or "interactive"/"loaded"?

(或者可能是 document.readyState 有时仍然有值加载?)

(Or could it be that document.readyState sometimes still has the value "loading"?)

在您的答案中,请提供对权威来源的引用。

In your answer please provide a reference to an authoritative source.

您可能会想:为什么不只是听 readystatechange ?这是因为Android 2.3.5标准浏览器是一个目标平台,它没有实现 readystatechange 事件。

You may wonder: Why not just listen to readystatechange? It is because the Android 2.3.5 standard browser is a target platform, and it does not implement the readystatechange event.

推荐答案

readyState 属性的值始终为interactive DOMContentLoaded 已触发。事实证明,MDN 文档声称: / p>

The value of the readyState property is always "interactive" when DOMContentLoaded has fired. This is evidenced by the fact that the MDN documentation claims:

document.onreadystatechange = function () {
  if (document.readyState == "interactive") {
    initApplication();
  }
}

可与 DOMContentLoaded 处理程序。您还可以查看规范这里,其中重申了这一点。

is interchangeable with a DOMContentLoaded handler. You can also have a look at the spec here, which reiterates this.

这篇关于在DOMContentLoaded上的document.readyState?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆