Folks,
I cannot help thinking that somehow the rendering of components and their
positions are skewed someway... under the hood.
I am unable to calculate the position of my component on the page.
Does anyone have a reliable method for calculating x,y ?
My code lives in a *.script file
I have these but they are off by 40 or so pixels for both x and y.
Thanks in advance...
function getXX(oNode) {
var x = 0;
while ( oNode ) {
x += oNode.offsetLeft;
oNode = oNode.offsetParent;
}
return x;
}
function getYY(oNode) {
var y = 0;
while (oNode){
y += oNode.offsetTop;
oNode = oNode.offsetParent;
}
return y;
}
function getNodePoss(oNode) {
var x = getXX(oNode);
var y = getYY(oNode);
//return { x: x - (oNode.clientWidth + oNode.offsetWidth),
// y: y - (oNode.clientHeight + oNode.offsetHeight) };
return { x: x - (oNode.offsetWidth),
y: y - (oNode.offsetHeight) };
}
Best regards
Ken in nashua
_________________________________________________________________
Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008