View Full Version : Controlling Scrollbar positioning?

Mar 14th, 2008, 08:41 PM
How an I control the amount of information that is shown on the page while I scroll using js? For instance, as I scroll down a page I would like more information to be shown. Thanks for you help in advance.

Mar 14th, 2008, 10:28 PM
if(document.body.scrollTop > some_value)
document.getElementById("the_element_to_display").style.display = "block";

i think is what you're looking for, better help comes with a more accurate description of what you're doing (code, link, etc.)

Mar 14th, 2008, 10:44 PM
I am sorry. I thought I did post the code. My mistake. Thank you for the code . If you wanted to look further... the code is attached (tested in IE). The reason I am searching for this is the highlighted bar that appears over each <tr> in the attached code... when the highlighted bar gets to the last line you cannot see the lines ahead of it. I would want the line highlighted plus the information ahead to show. Therefore, I believed that I would need to position the scrollbar. I could be right or wrong. Thanks again for your help.

Mar 14th, 2008, 11:06 PM
document.scrollTop = hilightedElement.offsetTop;

i think is about as close as you'd get, of course you'll have to find a reliable way to get the top property of the element, since it's in a flow layout (also the distance between the top of the table and the top of the page will need to be accounted for), this will automatically send the element to the top of the window (scroll so that it's at the top or to the end of the document, whichever one makes more sense) or.... you could do document.location="scrollingtext1.html#" + rangeName to have the browser jump to that section (of course there'll be some nasty page reloading involved)

Mar 14th, 2008, 11:18 PM
Thanks Mike for your help. I will try it now. Thanks. :)