Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Vertical scrolling in a DIV

    Hi.
    I use a DIV element to display a tree. The tree looks like the Window Explorer, with folders and +/- to go up or down in the tree. I use overflow: auto; to get scrollbars if the tree gets to big for the DIV.
    My problem is:
    I scroll down to a line and press for example + ,
    the screen refreshes with data from my servlet. And the scrollbar starts at the top again.
    I want to have position of the scrollbar at the point I was before the update.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Try using DHTML scrolling methods scroll(x,y) or scrollTo(x,y) within an ID idetified object (your DIV)...

    Try document.getEmentntById(id).scrollTo(x,y)

    I haven't tasted but it might work
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    getElementById
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    Hi.
    Thanks for the tip.
    I use document.getElementById("id").scrollLeft = x
    and document.getElementById("id").scrollTop = y
    instead of scrollTo(x,y).
    It seems to work.

    Mari

  • #5
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Will this work w/ both NS6 and IE6? (only have one at work, but need to account for both eventually)
    Wayne Christian

  • #6
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi.
    I have not tested in NS6 but I use the following:

    var isIE = 0;
    if( navigator.appName.indexOf('Microsoft Internet Explorer') != -1 ){isIE = 1;}

    function scrollDIVTo(x,y){
    if( isIE ){
    document.getElementById("liste").scrollLeft = x;
    document.getElementById("liste").scrollTop = y;
    return;
    }
    else{
    scrollTo( x,y );
    return;
    }
    }

    Mari.

  • #7
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I'm trying to scroll an element of a DIV into view.
    Ive got a table with 40 rows within a scrollable div.

    I tried

    div.scrollTop = node.offsetTop

    where node is a table cell within a scrollable div.
    This works fine as long as the node is not close to the bottom of the table. But if the node is < div.clientHeight from the end of the div, the div.clientHeight is reduced. Its really crazy.

    (I know node.offsetTop is the offset from the top of the table. There's nothing between the top of the table and the top of the div). I noticed that there's a scrollIntoView method, but unfortunately it scrolls the entire page and not just the div content. Has anyone done something like this?
    Wayne Christian


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •