JavaScript API
Get Image Width/Height - getImageWidth() & getImageHeight()
The functions return the width or height of an image.
NOTE: All the browsers except Netscape 4.x just call getElementWidth(myImage) or getElementHeight(myImage) to get the width or height.
The Code
function getImageWidth(myImage) {
var x, obj;
if (document.layers) {
var img = getImage(myImage);
return img.width;
} else {
return getElementWidth(myImage);
}
return -1;
}
function getImageHeight(myImage) {
var y, obj;
if (document.layers) {
var img = getImage(myImage);
return img.height;
} else {
return getElementHeight(myImage);
}
return -1;
}
|