Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrollTop in Firefox? 1

Status
Not open for further replies.

elck

Programmer
Apr 19, 2004
176
NL
I'd like a pop-up-layer to appear 10px below the top of the window, even when the document is scrolled down.

In IE I used to use document.all.th.scrollTop to calculate where the window scrolled to. ("th" is the id of the body)

But in Mozilla scrollTop it does not seem to work.
Do you
know a way or work-around?
please?
 
Yeah, using
Code:
self.pageYOffset
to find the scroll offset should work for you, it provides the exact same information in firefox.

hope that helps

"Whether you think that you can, or that you can't, you are usually right." - Henry Ford
 
Yeah, works fine, thanks.


Now something else happens.

In IE scrollTop does not work anymore, and pageYOffset still doesnot work.

That happened as soon as I put <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"at the top of the document.

Of course I could take that out, but then the page looks completely different in Mozilla and Firefox.

I so wished I was still only writing for IE, it made the world a lot easier! sigh..
 
WOW
I played around with this for awhile in Firefox. Nothing at all was happening, doctype removed and all. Then I realized I had javascript disabled, heh. Took a look at it in IE again, then went to google. Turns out document.body.scrollTop and its related objects are being phased out under the new HTML standards. The new accepted code to get the scrollTop distance in IE is
Code:
document.documentElement.scrollTop

hope that fixes it for you

"Insane people are always sure that they are fine. It is only the sane people who are willing to admit that they are crazy." - Nora Ephron
 
Wow, great!
Thanks Dookie!

Did you find any usefull sites where these issues are clearly explained?

Anyways, it works now, thanks again!

 
Probably the place to find them clearly explained is by other people in forums like this one. I found some helpful things at I also looked around at and DevGuru is always good,
hope that helps

"Insane people are always sure that they are fine. It is only the sane people who are willing to admit that they are crazy." - Nora Ephron
 
I 'favorised' the forum, I knew devguru (and use it extensively) for their javascript section, but never browsed further. The w3c I knew, but 1/2 the time I cannot find what I look for.
Thanks for the forum and the other side of devguru!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top