The JavaScript Image Object is a property of the document object.
Properties
border - The width of the border around the image in pixels.
complete - A boolean value which identifies whether an image is completely loaded yet.
height - The read only height of the image in pixels.
hspace - The read only amount of horizontal space to the left and right sides of the image.
lowsrc - The read or write string giving the URL of an alternate image for low resolution screen display.
name - The assigned name of the image.
prototype - Used for adding user-specified properties to the image.
src - The URL of the image to be displayed. It is a read/write string.
vspace - The read only vertical space above and below the image.
width - The read only width of the image in pixels.
Events
onAbort
onError
onLoad
比如說
function getImgSize(imgSrc)
{
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
alert ('The image size is '+width+'*'+height);
}
</script>
{
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
alert ('The image size is '+width+'*'+height);
}
</script>
onclick="getImgSize('images/testout_r1_c2.jpg')"