开发者

window.onload vs. body.onload vs. document.onready [duplicate]

开发者 https://www.devze.com 2023-01-11 22:11 出处:网络
This question already has answers here: 开发者_开发问答window.onload vs $(document).ready() (17 answers)
This question already has answers here: 开发者_开发问答 window.onload vs $(document).ready() (17 answers) Closed 7 years ago.

What is the difference between window.onload, document.onready and body.onload ?


window.onload will wait until all assets have finished downloading, such as images and scripts.

DOM ready waits until you can access the DOM via the API.

As a side note, in this day and age, you ought to be using window.addEventListener('load', function() { }, false) or attachEvent() for older IEs.

0

精彩评论

暂无评论...
验证码 换一张
取 消