[web] Knowing how far a user scrolled down
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.
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.
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)
it says that in IE6 you ought to use document.documentElement.scrollTop instead, but document.documentBody.scrollTop should work too (in compatibility mode)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement