Javascript 加载与 DOMContentLoaded 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8835413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between load vs DOMContentLoaded
提问by Sudhir
Possible Duplicate:
Difference between DOMContentLoaded and Load events
Whats the difference between
有什么区别
window.addEventListener("load", load, false);
and
和
document.addEventListener("DOMContentLoaded", load, false);
?
?
回答by Krizz
DOMContentLoaded
- the whole document (HTML) has been loaded.load
- the whole document and its resources (e.g. images, iframes, scripts) have been loaded.
DOMContentLoaded
- 整个文档 (HTML) 已加载。load
- 整个文档及其资源(例如图像、iframe、脚本)已加载。
回答by Vadim Gulyakin
DOMContentLoaded awaits only for HTML and scripts to be loaded.
window.onload and iframe.onload triggers when the page is fully loaded with all dependent resources including images and styles.
DOMContentLoaded 仅等待加载 HTML 和脚本。
window.onload 和 iframe.onload 在页面完全加载所有依赖资源(包括图像和样式)时触发。
Here is more details you can find http://javascript.info/tutorial/onload-ondomcontentloaded
这里有更多细节,你可以找到http://javascript.info/tutorial/onload-ondomcontentloaded