We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

当文档的readyState属性发生改变,readystatechange事件会被触发。

常规信息

规范
HTML5
接口
Event
是否冒泡
能否取消
目标
Document
默认行为

属性

Property Type Description
target 只读 EventTarget The event target (the topmost target in the DOM tree).
type 只读 DOMString The type of event.
bubbles 只读 Boolean Whether the event normally bubbles or not.
cancelable 只读 Boolean Whether the event is cancellable or not.

示例

document.readyState === "complete";
// true


// 替代 DOMContentLoaded
document.onreadystatechange = function () {
    if (document.readyState === "interactive") {
        initApplication();
    }
}

浏览器兼容性

IE 浏览器是一直支持readystatechange事件的,可作为 DOMContentLoaded 事件的替代方法(参见Browser compatibility的注释 [2])。

相关事件

文档标签和贡献者

此页面的贡献者: zhangchen, fscholz, abc45628
最后编辑者: zhangchen,