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'); });