六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 129|回复: 0

textarea 设置到鼠标事件设置到最下方

[复制链接]

升级  20%

22

主题

22

主题

22

主题

秀才

Rank: 2

积分
80
 楼主| 发表于 2013-2-7 20:03:53 | 显示全部楼层 |阅读模式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>客服一网通 www.kfewt.com </title>

</head>
<body  >
<form   id=form1>
<input   type=text   onclick= "AppendText(this) ">
<textarea   id=txt   name=txt   onpropertychange="ScrollToBottom();"    onfocus= "ScrollToBottom();"   rows=9>
111111asdf   ;a;fjk   aldfja;df   ajk;df   ;aldsfja;sdf
22222   adsfads
3333fasd   fasdf   adfasdfasdf
444asdf
555asdf   asdf   adfasdfasdfasdf
666asdf   adf
777adsfa
8888888   sdf   asdfasdfasdf
99999a   sdfasdfasdfasdf   asdfasdf
0000000   asdf   asdf
1
2
3
4
5

</textarea>


</form>
<script   language=javascript>
function   ScrollToBottom()   {
document.getElementById("txt").scrollTop=document.getElementById("txt").scrollHeight;

}
ScrollToBottom();
function   AppendText(t)   {
document.getElementById("txt").value   +=   "\n "   +   t.value   ;
ScrollToBottom();
}

function   test()//显示最后一行
{   
    document.all.txt.scrollTop=document.all.txt.scrollHeight;   
}  

  
</script>


</body>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表