Jump to content
  • Advertisement
Sign in to follow this  
Sander

[web] Knowing how far a user scrolled down

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any way to read/set how far a user has scrolled down on a page? I am working with fairly large tables filled with data that occasionally get updated, after which the page refreshes. I would like to take the user down again to where he was so that he doesn't have to scroll down all the way again. I tried refreshing with #tags on the changed data but that didn't work so I am now looking for a javascript solution to it. Cross-browser preferred but out company defaults on MSIE5.5 with the occasional MSIE6 visitor, so I could probabely live with a propriety solution.

Share this post


Link to post
Share on other sites
Advertisement
document.body.scrollTop, works with both IE5.5 and IE6, should work with other browsers too...

when submitting a form, you just store the value of document.body.scrollTop to some hidden form's input variable, and when coming back to the page, just set document.body.scrollTop to the stored value.

Share this post


Link to post
Share on other sites
Quote:
Original post by kango19
document.body.scrollTop, works with both IE5.5 and IE6, should work with other browsers too...

document.body.scrollTop also works in Gecko-based browsers.

Share this post


Link to post
Share on other sites
I've just found this page: http://www.quirksmode.org/js/doctypes.html
it says that in IE6 you ought to use document.documentElement.scrollTop instead, but document.documentBody.scrollTop should work too (in compatibility mode)

Share this post


Link to post
Share on other sites
I finally managed to implement this at work and it's working great [smile]

Thanks all!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!