在DOMContentLoaded上的document.readyState? [英] document.readyState on DOMContentLoaded?
问题描述
在支持事件 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 ofdocument.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屋!