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()%>