<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
document.write("<span id=lblTime width='118px' height='11px' Font-Size='9pt' style='color:Red' ></span>") //输出显示日期的容器
//每1000毫秒(即1秒) 执行一次本段代码
setInterval("lblTime.innerText=new Date().toLocaleString()", 1000)
</script>
</div>
</form>
</body>
</html>
<html>
<body>
<form>
<input type="text" id="clock" size="35" />
<script language=javascript>
var int=window.setInterval("clock()",1)
function clock()
{
var t=new Date()
document.getElementById("clock").value=t
}
</script>
</form>
<button οnclick="window.clearInterval(int)">Stop interval</button>
<button οnclick="window.clearInterval(int);int=window.setInterval('clock()',1)">Start interval</button>
</body>
</html>