日期:2014-05-16  浏览次数:20321 次

js显示一个时钟

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
<script type="text/javascript">
function startTime(){
?var today = new Date();
?var H = checkTime(today.getHours());
?var M = checkTime(today.getMinutes());
?var S = checkTime(today.getSeconds());
?document.getElementById('txt').innerHTML = H+':'+M+':'+S;
?setTimeout('startTime()',500)
}

function checkTime(i){
?if(i<10){
??return "0"+i;
?}else{
??return i;
?}
}
</script>
</head>
<body onload="startTime()">?
<div id="txt"></div>
</body>
</html>