送分:聊天室前台显示的问题! RT~ 聊天室是用java+ajax写的,用户发的消息要从下往上走 比如,当前用户端显示的第一条消息是从显示窗口下面显示出来的,第二条消息也是从下面显示的...以此类推 请达人解答具体做法,本人新手!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就用appendChild() 按顺序加入,就是你要的效果了。 LZ 简单模拟了一下,应该是这样吧...<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><style type="text/css">#chatContainer{ width:500px; height:100px; overflow:hidden; border:1px solid #ccc; position:relative;}#chatMsg{ position:absolute; bottom:0px; overflow:auto; width:100%;}</style><script type="text/javascript">function sendMsg(){ var txt = document.getElementById("txtMsg"); var chat = document.getElementById("chatMsg"); chat.innerHTML += txt.value +"<br/>"; chat.scrollTop += 50; if(chat.offsetHeight > chat.parentNode.offsetHeight){ chat.style.height = chat.parentNode.offsetHeight + "px"; } txt.value = ""; txt.focus();}</script></head><body><div id="chatContainer"> <div id="chatMsg"></div></div><input type="text" id="txtMsg" /><input type="button" value=" 发送 " onclick="sendMsg();" /></body></html> jquery easyui 为什么图标无法显示 html代码怎么转换成javascript的DOM对象 关于Jqplot中饼图上百分比字体颜色改变的问题! name: aaaa 这种形式是表示什么意思?谁能帮忙讲解下该怎么应用? 请问怎么捕获当前对象左边的<input>框? 关于鼠标停留的问题 如何将捕获到的键盘代码连接成一个串 不知道如果要出现如我们csdn中的有短消息提示的效果,要如何实现? TC & Javascript 求帮组! HTML+CSS样式表快速生成器测试版 tomcat的启动时有InvocationTargetException异常
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
#chatContainer{
width:500px; height:100px; overflow:hidden; border:1px solid #ccc; position:relative;
}
#chatMsg{
position:absolute; bottom:0px; overflow:auto; width:100%;
}
</style>
<script type="text/javascript">function sendMsg(){
var txt = document.getElementById("txtMsg");
var chat = document.getElementById("chatMsg");
chat.innerHTML += txt.value +"<br/>";
chat.scrollTop += 50;
if(chat.offsetHeight > chat.parentNode.offsetHeight){
chat.style.height = chat.parentNode.offsetHeight + "px";
}
txt.value = "";
txt.focus();
}
</script>
</head><body>
<div id="chatContainer">
<div id="chatMsg"></div>
</div>
<input type="text" id="txtMsg" /><input type="button" value=" 发送 " onclick="sendMsg();" />
</body>
</html>