Last active
August 8, 2017 06:33
-
-
Save suncn/ea3defe1f58c6e1565b3b088608d0abc to your computer and use it in GitHub Desktop.
页面加载完成执行事件load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", function() { | |
// ...代码... | |
}, false); | |
window.addEventListener("load", function() { | |
// ...代码... | |
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOM文档加载的步骤为 | |
解析HTML结构。 | |
加载外部脚本和样式表文件。 | |
解析并执行脚本代码。 | |
DOM树构建完成。//DOMContentLoaded | |
加载图片等外部文件。 | |
页面加载完毕。//load | |
在第4步,会触发DOMContentLoaded事件。在第6步,触发load事件。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment