XMLHTTP方式读服务器时间(可在服务器端: s.asp自行插入读数据库代码):


客户端time.htm

<script language=JavaScript>
 function getonlinenum()
 {
  var objXMLHTTP=new ActiveXObject("MICROSOFT.XMLHTTP");
  objXMLHTTP.open("GET","s.asp",false);
  objXMLHTTP.send("");
  var strReturn=objXMLHTTP.ResponseText;
  online_num.innerHTML="server time:" + strReturn; 
 }
    </script>
    </head>
    <body onload="setInterval('getonlinenum()',1000)">
<span id=online_num></span>

-----------------------------
服务器端: s.asp

<%Response.Expires=-1
response.ContentType ="text/xml"%>
<?xml version='1.0' encoding='gb2312'?>
<%=now()%>

posted on 2005-05-07 14:44  dahai.net  阅读(401)  评论(0编辑  收藏  举报