JavaScript API
Get Element Width/Height - getElementHeight() & getElementWidth()
The functions return the width or height of an object.
NOTE: This code will not work for images in Netscape 4.x. Use getImageWidth and getImageHeight instead.
The Code
function getElementHeight(Elem) {
if (ns4) {
var elem = getObjNN4(document, Elem);
return elem.clip.height;
} else {
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all){
var elem = document.all[Elem];
}
if (op5) {
xPos = elem.style.pixelHeight;
} else {
xPos = elem.offsetHeight;
}
return xPos;
}
}
function getElementWidth(Elem) {
if (ns4) {
var elem = getObjNN4(document, Elem);
return elem.clip.width;
} else {
if(document.getElementById) {
var elem = document.getElementById(Elem);
} else if (document.all){
var elem = document.all[Elem];
}
if (op5) {
xPos = elem.style.pixelWidth;
} else {
xPos = elem.offsetWidth;
}
return xPos;
}
}
|