|
-
Nov 3rd, 2006, 12:10 PM
#1
[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
-
Nov 6th, 2006, 03:53 AM
#2
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 6th, 2006, 10:23 AM
#3
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.
-
Nov 6th, 2006, 07:00 PM
#4
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.
-
Nov 6th, 2006, 07:53 PM
#5
Re: [JS] scroll overflowed element
I'm an idiot. Setting scrollTop works. Thanks.
-
Nov 6th, 2006, 08:05 PM
#6
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
Last edited by CornedBee; Nov 6th, 2006 at 08:15 PM.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 6th, 2006, 11:42 PM
#7
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|