Forum Moderators: open

Message Too Old, No Replies

<DIV style=overflow:auto set the scroll bar

I want to set the scroll bar position

         

jetteroheller

8:09 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I just think on

<div style=width:150;height:300;overflow:auto>

Where a much longer menu is displayed.

But when the current selected item of the menu is 450 pixel down, it would be not visible without scrolling.

So I would like to set the position, that maybe
the first 200 pixel are not displayed and the sceleted item is visible 250 pixel below the top of the DIV.

But how to set the scroll bar position?

createErrorMsg

8:37 pm on May 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you mean you want to load the page and have this div start partially scrolled? Try using named anchors in the div's content, and include the anchor link in the url that links to the page, as in...

url:
www.example.com/index.htm#middle

html:
<div id="the_scrolling_div">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum...amet.</p>
<p>Lorem ipsum...amet.</p>
<p>Lorem ipsum...amet.</p>
<h2><a name="middle">Dolor Sit</a></h2>
<p>Lorem ipsum...amet.</p>
<p>Lorem ipsum...amet.</p>
</div>

...this would upon clicking the link, automaticaly scroll the div to the <h2> tag.

Also note that properties which accept numerical values (width, height, margin, etc) need to have a unit specified, unless the number is 0.

cEM

<added>Just tested this and it works like a charm.</added>

jetteroheller

10:42 am on May 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would have to change all the links from

my-domain.com/theme/theme.htm
to
my-domain.com/theme/theme.htm#middle

This is a high risk for confusing search engines.

No way, without changing URLs?

tedster

3:28 pm on May 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a high risk for confusing search engines.

Not in my experience - search engines do not worry about the named anchors that apear after a "#" in the url, they only work with the full page.

jetteroheller

7:52 pm on May 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not in my experience - search engines do not worry about the named anchors that apear after a "#" in the url, they only work with the full page.

But visitors coming from a search engine would not have the "#", so the DIV would not be scrolled.

I just tested an other method

document.getElementById('dirsub').doScroll('scrollbarPageDown');

Worked great from the command line.

But as I put it on the end of the page into a Javascript, I got

"Data not available at this time"