Click to See Complete Forum and Search --> : quick easy question


havik
04-11-2003, 10:39 AM
My minds' gone numb.

How do we use javascript to determine how far the top of a div layer is from the top of the browser window? I'll need it for NS6 and IE.

I tried using this for NS6:
window.pageYOffset;

and this for IE:
document.body.scrollTop;

But those aren't working correctly.

Havik

viravan
04-11-2003, 11:05 AM
If you're trying to get the info while the page is being loaded, you'll get an inaccurate reading.... Did you try to get the info via a function activated by "body onload".

:)

V.V.

khalidali63
04-11-2003, 11:07 AM
if you want to know the Y and X co-ords for a div
you should use

div.style.top

works for both NS6 and IE6

Cheers

Khalid