DHTML reference image with out position:absolute
Camden Daily
cdaily at GMAIL.COM
Mon May 16 07:17:14 PDT 2005
So, for example, you just need to find out the exact (x, y)
coordinates of an element on your page? You could do it using
javascript:
mapElem = document.getElementById("yourMapId");
mapMinX = findPosX(mapElem);
mapMinY = findPosY(mapElem);
// find how many pixels an element is from the left of the screen
// by recursively traversing up the tree and summing the offsets
function findPosX(elem) {
var left = 0;
if (elem.offsetParent) {
while (elem.offsetParent) {
left += elem.offsetLeft
elem = elem.offsetParent;
}
}
else if (elem.x) {
left += elem.x;
}
return left;
}
// find how many pixels an element is from the top of the screen
// by recursively traversing up the tree and summing the offsets
function findPosY(elem) {
var top = 0;
if (elem.offsetParent) {
while (elem.offsetParent) {
top += elem.offsetTop
elem = elem.offsetParent;
}
}
else if (elem.y) {
top += elem.y; }
return top;
}
Camden Daily
Prudential Preferred Properties
http://www.prupref.com
More information about the MapServer-users
mailing list