我自己做的聊天室,是用table排的
div来显示聊天内容。我想实现自动滚屏,怎么在div层里怎么自动滚屏就是下拉框自动往下移动
还有我用了两个div实现分屏,但是我不知道第二个div里面的内容怎么限定是只显示和自己相关的内容,而不显示其他无关内容,弄了半天没有出来,
这列举了一点我写的script,我用ajax做的
//发送消息
function send()
{
var txtContent = document.all( "content ").value; //文本框输入内容
if (txtContent == " ") return;
var user_to = document.all( "userlist ").value; //聊天对象
var textcolor = document.all( "textcolor ").value; //颜色
var expression = document.all( "expression ").value; //表情
var isPublic = !(document.all( "isSecret ").checked); //是否密谈
//调用服务器端方法发送消息
Chat.ChatRoom.SendMsg(txtContent, user_to, textcolor, expression, isPublic);
//更新聊天内容显示
var div = document.all( "chatcontent ");
var div1 =document.all( "chat1 ");
var isLeft = !(document.all( "isLeft ").checked);
div.innerHTML = div.innerHTML+Chat.ChatRoom.GetNewMsgString().value;
if(!isLeft)
div1.innerHTML+=div1.innerHTML+Chat.ChatRoom.GetNewMsgString().value;
//清空输入框
document.all( "content ").value = " ";
}
//定时更新聊天内容
function refresh_chatcontent()
{
//调用服务器方法获取最新消息的HTML字符串
var div = document.all( "chatcontent ");
var div1 =document.all( "chat1 ");
var strNewMsg =Chat.ChatRoom.GetNewMsgString().value;
var isLeft = !(document.all( "isLeft ").checked);
//判断是否为空,避免不必要的更新
if (strNewMsg != " ")
{
div.innerHTML =div.innerHTML+strNewMsg;
if(!isLeft)
div1.innerHTML=div.innerHTML+strNewMsg;
}
//定时更新
window.setTimeout(refresh_chatcontent, 1000);
}
//是否分屏
function isCleft()
{
var isLeft = !(document.all( "isLeft ").checked); //是否分屏
var div = document.all( "chatcontent ");
var div1 =document.all( "chat1 ");
if(!isLeft)
{
div.style.height= "60% ";
div1.style.display= "block ";
div1.style.height= "40% "