Waiting for image to load in JavaScript
var img = new Image(); img.onload = function() { alert(“Height: ” + this.height); } img.src = “http://path/to/image.jpg”; Note that it’s important to do it in the order above: First attach the handler, then set the src. If you do it the other way around, and the image is in cache, you may miss the event. … Read more