<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<script language=Javascript>
function time(){
//獲得顯示時間的div
t_div = document.getElementById('showtime');
var now=new Date()
//替換div內容
t_div.innerHTML = "現在是"+now.getFullYear()
+"年"+(now.getMonth()+1)+"月"+now.getDate()
+"日"+now.getHours()+"時"+now.getMinutes()
+"分"+now.getSeconds()+"秒";
//等待一秒鐘後調用time方法,由於settimeout在time方法內,所以可以無限調用
setTimeout(time,1000);
}
</script>
</head><body onload="time()">
<div id="showtime"></div>
</body>
</html>