DynamicImage

Test the Script This script will create and append an image to the DOM. Once the image is loaded it will alert the width of the newly added image.

function AddImage()
{
   var eImg = document.createElement("img");
   eImg.onload = function(){ alert(this.width); }
   eImg.src = "small.jpg";
   document.getElementById("body").appendChild( eImg );
}
Last Updated : 28/12/2005 @ 15:25