How to scroll a TextArea

Discussion in 'Javascript' started by Stefano Incontri, Jul 3, 2003.

  1. Hi All,

    how can I scroll a TextArea to its last position at the bottom?

    Thanks,
    Stefano
    Stefano Incontri, Jul 3, 2003
    #1
    1. Advertising

  2. Stefano Incontri

    Bagbourne Guest

    "Stefano Incontri" <> wrote in message
    news:p...
    > Hi All,
    >
    > how can I scroll a TextArea to its last position at the bottom?


    element.scrollTop = element.scrollHeight - element.clientHeight;
    Bagbourne, Jul 4, 2003
    #2
    1. Advertising

  3. Stefano Incontri

    Yep Guest

    "Stefano Incontri" <> wrote in message news:<>...

    > how can I scroll a TextArea to its last position at the bottom?


    In IE, collapsing a TEXTAREA range to the end and selecting it should
    result into a scrolldown; as for other browsers I don't think it's
    currently doable.


    <textarea id="ta" rows="5" cols="30">
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    </textarea>

    <input type="button" value="scroll" onclick="f('ta')" />

    <script type="text/javascript">
    function f(ta_id){
    var d=document, ta, rng;
    if(d.all){
    ta=d.all[ta_id];
    if(ta && ta.createTextRange){
    rng=ta.createTextRange();
    rng.collapse(false);
    rng.select();
    }
    }
    }
    </script>
    Yep, Jul 5, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe
    Replies:
    1
    Views:
    669
    Alan Cole
    Nov 7, 2004
  2. Augustus
    Replies:
    1
    Views:
    340
    Ken Schaefer
    Sep 10, 2003
  3. Textarea Inside of a textarea

    , Feb 4, 2006, in forum: ASP General
    Replies:
    6
    Views:
    318
    Anthony Jones
    Feb 5, 2006
  4. Replies:
    0
    Views:
    79
  5. Replies:
    1
    Views:
    298
    Bart Van der Donck
    Jul 4, 2007
Loading...

Share This Page