Forum Moderators: open
<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?
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>
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"