<div>以下是用户发表的留言 </div>
<div id="aaa"></div>
<script language="javascript">
...
  document.getElementById("aaa").innerHTML = text;//text就是获取到的留言
...
</script>

解决方案 »

  1.   

    comments.html
    //////////////////////////////////////////////////////<script language='javascript'>var xmlHttp;function getXMLHttpRequest(){
      
      if(window.ActiveXObject){
        try {
          xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){
          try{
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch(e){
            xmlHttp = false ;
          }
        }
      }
      else if(window.XMLHttpRequest)
        xmlHttp = new XMLHttpRequest();
      return xmlHttp;
    }getXMLHttpRequest();function sendRequest(){
     var xmlHttp = getXMLHttpRequest();
     var comments = document.getElementById('comments').value; var url = 'comments.php'; if (!xmlHttp){
       return false;
      }
      
      xmlHttp.onreadystatechange = getResponse;

      
      xmlHttp.open('POST',url,true);
      xmlHttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); 
      xmlHttp.send('starttime='+escape(comments));
    }function getResponse(){
    if(xmlHttp.readyState < 4){
    document.getElementById('status').innerHTML = 'waiting...';
    }
        if(xmlHttp.readyState == 4){
    if(xmlHttp.status == 200){
    response = xmlHttp.responseText;
    document.getElementById('status').innerHTML = unescape(response);
    }
    else
    {
    document.getElementById('status').innerHTML = 'error!';
    }
     }
    }window.onload = function(){
    document.onkeypress = keypress;
    }//兼容ie和firefox
    function keypress(evt){
    var e = evt? evt : window.event;
    if(e.keyCode == 13)
    sendRequest();
    }
    </script>留言内容:<input type='text' name='comments' value=""/><input type="button" id="checkmobile" value="query" onclick="sendRequest()" /><br/><br/>
    <br/><div id="status" ></div>comments.php
    ///////////////////////////////////////////////////////////////
    <?php
    echo $_POST['comments'];
    ?>
      

  2.   

    上面的方法才是通过ajax方式,用在你这个需求上完全多此一举
      

  3.   

    不是读取
    是向div里面写入
      

  4.   

    <div id="message">以下是用户发表的留言 </div> 
    <div id="aaa"> </div> 
    <script language="javascript"> 
    ... 
      document.getElementById("aaa").innerHTML = document.getElementById("message").innerHTML ;//给新的div赋值
    ... 
    </script>