By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

How to scroll a TextArea

P: n/a
Hi All,

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

Thanks,
Stefano
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Stefano Incontri" <st********@iol.it> wrote in message
news:pa****************************@iol.it...
Hi All,

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


element.scrollTop = element.scrollHeight - element.clientHeight;

Jul 20 '05 #2

P: n/a
Yep
"Stefano Incontri" <st********@iol.it> wrote in message news:<pa****************************@iol.it>...
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>
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.