dom 加載監聽事件 及解析

 

document.addEventListener("DOMContentLoaded", function (_event) {
    console.log("初始DOM 加載並解析");
});
window.addEventListener("load", function (_event) {
    console.log("window 全部資源加載完成");
});

document.addEventListener('readystatechange', function (_event) {
    console.log(document.readyState);
    if (document.readyState === "complete") {
        console.log('初始DOM,加載解析完成')
    }
});

window.addEventListener("beforeunload", function (event) {
    console.log('即將關閉')
    event.returnValue = "\o/";
});
window.addEventListener('unload', function (_event) {
    console.log('即將關閉1');
});
相關文章
相關標籤/搜索