[web] Knowing how far a user scrolled down

Started by
3 comments, last by Sander 19 years, 2 months ago
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 &#106avascript 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.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

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.
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.
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)
I finally managed to implement this at work and it's working great [smile]

Thanks all!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement