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

如何用ASP显示当前时间,并每秒更新
请高手指教!!!

------解决方案--------------------
asp页面time.asp

<%
if resquest("do")="ok" then
response.write now()
end if
%>

请求页面time.htm
<div id="box"></div>
<script>
function $(ID) {
if (document.getElementById && document.getElementById(ID)) {
return document.getElementById(ID);
} else if (document.all && document.all(ID)) {
return document.all(ID);
} else if (document.layers && document.layers[ID]) {
return document.layers[ID];
} else {
return false;
}
}
function AJAX() {
var $HTTP = false;
var $Me = this;
try {
$HTTP = new XMLHttpRequest;
} catch(e) {
try {
$HTTP = new ActiveXObject("MSXML2.XMLHTTP");
} catch(e2) {
try {
$HTTP = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e3) {
$HTTP = false;
}
}
}
if (!$HTTP) {return false;}
this.method = "POST";
this.URL;
this.ASYNC = true;
this.content = "";
this.callback = function(obj) {return obj;}
this.send = function() {
if (!this.method||!this.URL||!this.ASYNC) {return false;}
$HTTP.open(this.method,this.URL,this.ASYNC);
if (this.method == "POST") {$HTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}
$HTTP.onreadystatechange = function() {$Me.callback($HTTP);}
if (this.method == "POST") {$HTTP.send(this.content);} else {$HTTP.send(null);}
}
}

var Ajax = new AJAX();
Ajax.method = "GET";
Ajax.URL = "time.asp?do=ok";
Ajax.callback = function($HTTP) {
if ($HTTP.readyState == 4) {
$("box").innerHTML = encodeURI($HTTP.responseText);
} else {}
}
Ajax.send();
</script>