[RESOLVED] [JS] scroll overflowed element
G'day
I believe there is a method of setting the scroll position of an element with overflow:auto and scrollbars, as I have seen it done. However I am not sure what this method is. Basically I want the scroll position to be set to its bottom-most position.
Any ideas?
Cheers
- P
Re: [JS] scroll overflowed element
I think they're called scrollTo() and scrollBy(). Not sure how to get proper values for the parameters, though. You could just pass a very large value to the y parameter of scrollBy.
Re: [JS] scroll overflowed element
Enjoy your reading. scrollTo is indeed what you should use. You can give it pixels. The values can be determined by reading the information behind the link.
Re: [JS] scroll overflowed element
Looks promising, but scrollTo doesn't appear to work on an element with its own scroll bars, only on the window itself, which doesn't have scroll bars.
Re: [JS] scroll overflowed element
I'm an idiot. Setting scrollTop works. Thanks.
Re: [RESOLVED] [JS] scroll overflowed element
In Firefox, you can set the scrollTop/scrollLeft properties. This line scrolls to the bottom:
Code:
var d = document.getElementById('thediv');
d.scrollTop = d.scrollHeight - d.clientHeight;
The code also works in Opera and Konqueror, and thus probably in Safari. No idea about IE.
Edit: Meh, that happens when you create a test page and test in three browsers before hitting "post": your post gets in 12 minutes after the OP says he's found the same solution ;)
Re: [RESOLVED] [JS] scroll overflowed element
Well, it's not for nothing, because I didn't test in Opera and Konqueror. :)
I dunno about IE either, but it's not an IE-compatible project at this stage.