Results 1 to 7 of 7

Thread: [RESOLVED] [JS] scroll overflowed element

  1. #1

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Resolved [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

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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.

  4. #4

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  5. #5

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [JS] scroll overflowed element

    I'm an idiot. Setting scrollTop works. Thanks.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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.

  7. #7

    Thread Starter
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width