javascript – window.onload vs. body.onload vs. document.onready-ThrowExceptions

Exception or error:

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

How to solve:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *