<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function disptime(){
var now=new Date();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
document.write("<h2>当前时间:"+hour+":"+minute+":"+second);
var time=setTimeout("disptime()",1000);
}
</script>
</head>
<body onload="disptime()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function disptime(){
var now=new Date();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
document.write("<h2>当前时间:"+hour+":"+minute+":"+second);
var time=setTimeout("disptime()",1000);
}
</script>
</head>
<body onload="disptime()">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page </title>
<script language="javascript">
var time;
function disptime(){
var now=new Date();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
document.getElementById("pad").innerHTML = "当前时间:"+hour+":"+minute+":"+second;
clearTimeout(time);
time=setTimeout("disptime()",1000);
}
</script>
</head>
<body onload="disptime()">
<form id="form1" runat="server">
<div id="pad">
</div>
</form>
</body>
</html>
window.onload = function() {
window.setInterval("disptime()",1000)
}
function disptime() {
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
document.write(" <h2>当前时间:" + hour + ":" + minute + ":" + second);
}还有你的document.write只能写入一次,换成div来显示时间
window.setInterval("disptime()",1000)
}:这个不会;