<html>
<head>
<title>在页面指定位置显示动态时间</title>
<script language="javascript">
<!--
function showClock() {
d = new Date();
hours = d.getHours();
minutes = d.getMinutes();
seconds = d.getSeconds();
clck = (hours >= 12) ? "下午" : "上午";
hours = (hours > 12) ? hours-12 : hours;
hours = (hours < 10) ? "0"+hours : hours;
minutes = (minutes < 10) ? "0"+minutes : minutes;
seconds = (seconds < 10) ? "0"+seconds : seconds;
time = clck + " " + hours + ":" + minutes + ":" + seconds;
myclock.innerHTML = time;
setTimeout("showClock()", 1000);
}
//-->
</script>
</head>
<body onload="showClock()">
<div id="myclock" style="position:absolute;left:10px; top:50px;"></div>
</body>
</html>
浙公网安备 33010602011771号