L
Lit
Hi,
How can I get the Y-Position ( Vertical ) of an Control via JavaScript from
the top of the Window.
I have tried the following script but no luck I keep on getting 15
function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}
I don't understand why, I keep on getting 15 for an element in the middle of
the page that is 900 pixels down on the page.
The loop is going up the parents many times but the total answer is 15. I
have tried similar script that I found on the Internet but getting the same
result. is this due to some elements have no ID?
Thank you,
Lit
How can I get the Y-Position ( Vertical ) of an Control via JavaScript from
the top of the Window.
I have tried the following script but no luck I keep on getting 15
function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}
I don't understand why, I keep on getting 15 for an element in the middle of
the page that is 900 pixels down on the page.
The loop is going up the parents many times but the total answer is 15. I
have tried similar script that I found on the Internet but getting the same
result. is this due to some elements have no ID?
Thank you,
Lit