michael.futreal.com > jQuery > ready vs. onload > example 1

Image size at $(document).ready() time

In Firefox 2.0 (and possibly other browsers), you may find that the sentence below does not report the correct height of 100 pixels, offering 0 instead. This mistake occurs because of issues with when and how .ready() is triggered when jQuery is being executed in Firefox 2.0.

The Test

The image below is y pixels tall.

Saturn

What This Page is Doing

This page utilizes jQuery's built-in mechanism for deferring code execution until the DOM is completely loaded. Unfortunately, in some browsers (including Firefox 2.0), the DOM-done event is triggered before images are loaded and available for examination. In scenarios where a height attribute is not pre-specified, code that uses image dimensions can fail.


$(function() {
   $("#sizeReport").html($("#saturnID").height())
});

Read more about it or go ahead and see a work-around.