I ran into a problem on Chrome and Safari using jQuery to do some calculations using the widths of a strip of images.
When using my calculations in:
$(document).ready(function() {
/* some calculations with $("img").width() */
});
everything works just fine in IE6+ and Firefox, but it does not in Chrome and Safari: $(img).width() is 0 whether the image is already cached or not.
Using:
$(window).load(function() {
/* some calculations with $("img").width() */
});
it works in all the above mentioned browsers but the problem is it only starts when all images are completely loaded.
Is the webkit behaviour the expected behaviour or is there some webkit / jQuery bug causing the image properties not to be a part of the DOM?
If it is a problem with webkit / jQuery: Is there a way around it that will allow my script to execute earlier than in the above mentioned solution?
By the way, I am not using any inline properties for the image dimensions.