开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜