document.readyState on DOMContentLoaded?
在支持事件 DOMContentLoaded
和属性 document.readyState
的浏览器中:
In browsers that support the event DOMContentLoaded
and the property document.readyState
:
当
DOMContentLoaded
时,我可以假设document.readyState
将总是
complete
或interactive
/loaded
?
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.