Basic misunderstanding of attributes

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to display a large amount of text in a scrolling DIV. I want the
scrollbar positioned at the bottom when the page is first displayed. My
DHTML reference suggests this can be done using the scrollTop property. I
just can't figure out how to use it.

These three attempts didn't work:

<div scrollTop=1000>block of text</div>

<div style="scrollTop : 1000">block of text</div>

<div id="log">block of text</div>

This is the only thing that *does* work, but I have to click a link to get
it to go:

<div id="log">block of text</div>
function scroll() {
<a href="javascript:scroll()">click here</a>

There's got to be some simple syntax that I'm missing.

Re: Basic misunderstanding of attributes

Chris wrote:
Quoted text here. Click to load it
Quoted text here. Click to load it

Put this in your head element:
<script type="text/javascript" src="scrolltop.js"></script>

And this in scrolltop.js:
function setScrollTop() {
    var element = document.getElementById('foo');
    element.scrollTop = 100;
window.onload = setScrollTop;

But note that scrollTop is nonstandard, scrollTop won't work the same
because of text sizes (scrollTop is in pixels), and users may be
confused by documents scrolling on their own.

Site Timeline