可能重复:
Difference between DOMContentLoaded and Load events差Vs DOMContentLoaded
请告诉我
window.addEventListener("load", load, false);
和
document.addEventListener("DOMContentLoaded", load, false);
之间的差
?
可能重复:
Difference between DOMContentLoaded and Load events差Vs DOMContentLoaded
请告诉我
window.addEventListener("load", load, false);
和
document.addEventListener("DOMContentLoaded", load, false);
之间的差
?
DOMContentLoaded
- 整个文档(HTML)已加载。load
- 已加载整个文档及其资源(例如图像,iframe,脚本)。DOMContentLoaded仅等待HTML和要加载的脚本。
window.onload和iframe.onload会在页面完全加载所有相关资源(包括图像和样式)时触发。
下面是更多的细节,你可以找到http://javascript.info/tutorial/onload-ondomcontentloaded
你会发现答案http://stackoverflow.com/questions/2414750/difference-between-domcontentloaded-and-load-events时触发一个窗口对象的文档DOM内容已完成加载,但与“加载”不同,不会等到所有图像加载完毕。 – 2012-01-12 12:57:16