📌  相关文章
📜  页面加载完成后调用 javascript 函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:41.927000             🧑  作者: Mango

代码示例3
document.addEventListener('readystatechange', event => { 

    // When HTML/DOM elements are ready:
    if (event.target.readyState === "interactive") {   //does same as:  ..addEventListener("DOMContentLoaded"..
        alert("hi 1");
    }

    // When window loaded ( external resources are loaded too- `css`,`src`, etc...) 
    if (event.target.readyState === "complete") {
        alert("hi 2");
    }
});