JavaScript API
Get Image Left/Top - getImageTop() & getImageLeft()
The functions return the x or y co-ordinate of an image.
NOTE: All the browsers except Netscape 4.x just call getElementLeft(myImage) or getElementTop(myImage) to get the x or y co-ordinates.
The Code
function getImageTop(myImage) {
var y, obj;
if (document.layers) {
var img = getImage(myImage);
if (img.container != null)
return img.container.pageY + img.y;
else
return img.y;
} else {
return getElementTop(myImage);
}
return -1;
}
function getImageLeft(myImage) {
var x, obj;
if (document.layers) {
var img = getImage(myImage);
if (img.container != null)
return img.container.pageX + img.x;
else
return img.x;
} else {
return getElementLeft(myImage);
}
return -1;
}
|