日期:2014-05-17  浏览次数:20603 次

还是请教div层的问题
做了一个ajax聊天室,用asp.net做的
现在有个问题,我用两个div把显示内容的那里分成了两段,上面显示所有聊天内容,下面显示关于自己的聊天内容
但是现在我自己在自己的页面发送信息,下面的不显示,如果别人发,下面就显示别人发的内容
部分代码如下
javascript部分
//发送消息
    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   ownerdiv=document.all( "ownercontent ");
      div.innerHTML   =   div.innerHTML+Chat.ChatRoom.GetNewMsgString().value;  
      ownerdiv.innerHTML   =   ownerdiv.innerHTML+Chat.ChatRoom.GetOwnerString().value;   //GetOwnerString()为获取自己发给别人的消息或别人发给自己的消息方法
      //清空输入框
      document.all( "content ").value   =   " ";
    }
   
    //定时更新聊天内容
    function   refresh_chatcontent()
    {
      //调用服务器方法获取最新消息的HTML字符串
      var   div   =   document.all( "chatcontent ");
      var   ownerdiv=document.all( "ownercontent ");
      var   strNewMsg   =Chat.ChatRoom.GetNewMsgString().value;
      var   strOwnerMsg=Chat.ChatRoom.GetOwnerString().value;
      //判断是否为空,避免不必要的更新
      if   (strNewMsg   !=   " ")
      {
        div.innerHTML   =div.innerHTML+   strNewMsg;
      }
      if(strOwnerMsg!= " ")
        ownerdiv.innerHTML   =   ownerdiv.innerHTML+strOwnerMsg;
      //定时更新
      window.setTimeout(refresh_chatcontent,   1000);
    }
html部分
<div   id= "chatcontent "   style= "OVERFLOW-Y:   auto;WIDTH:   100%;POSITION:   relative;HEIGHT:   65% "> <FONT   face= "宋体 "> </FONT> </div>
<div   id= "ownercontent "   style= "OVERFLOW-Y:   auto;WIDTH:   100%;POSITION:   relative;HEIGHT:   35%;   background-color:#ffffcc "> <FONT   face= "宋体 "> </FONT> </div>
很苦恼,谢谢大家


------解决方案--------------------
读取资料不同显示在不同的地方,应该不难吧?