Scrolling in div

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chris@milwaukeejobs.com

    Scrolling in div

    Hello all - I'm trying to get a div element to scroll down when a new
    line of html is added to it. Here's my div element:

    <div id="initialtext "
    style="height:1 85px;width:390p x;overflow:scro ll;z-index: 91; position:
    absolute; visibility:visi ble;left:15px;t op:67px;"></div>

    And I have a function that adds text to this div:

    function addText(t)
    {
    var d = document.getEle mentById("initi altext");
    if (d)
    {
    d.innerHTML+=t;
    // Now I want the div to scroll down so I can see the
    new line!
    }
    }
    I've tried doScroll(), scrollTop(), and a bunch of other ideas I found
    in this group but cannot get anything to work! Thanks much for any
    input!
  • RobB

    #2
    Re: Scrolling in div

    chris@milwaukee jobs.com wrote in message news:<e0f03450. 0411301409.7c10 197f@posting.go ogle.com>...[color=blue]
    > Hello all - I'm trying to get a div element to scroll down when a new
    > line of html is added to it. Here's my div element:
    >
    > <div id="initialtext "
    > style="height:1 85px;width:390p x;overflow:scro ll;z-index: 91; position:
    > absolute; visibility:visi ble;left:15px;t op:67px;"></div>
    >
    > And I have a function that adds text to this div:
    >
    > function addText(t)
    > {
    > var d = document.getEle mentById("initi altext");
    > if (d)
    > {
    > d.innerHTML+=t;
    > // Now I want the div to scroll down so I can see the
    > new line!
    > }
    > }
    > I've tried doScroll(), scrollTop(), and a bunch of other ideas I found
    > in this group but cannot get anything to work! Thanks much for any
    > input![/color]

    Try:

    function addText(id, txt)
    {
    var el;
    if (el = document.getEle mentById(id))
    {
    el.innerHTML += txt;
    if (typeof el.scrollTop != 'undefined')
    setTimeout('doc ument.getElemen tById("'+id+'") .scrollTop=5000 ;', 50);
    }
    }

    Comment

    • chris@milwaukeejobs.com

      #3
      Re: Scrolling in div

      It works! Thanks so much!

      Comment

      Working...