window.onload vs. body.onload vs. document.onready [duplicate]
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.
精彩评论