<!DOCTYPE html> <html> <head lang="en">
<meta charset="UTF-8">
<title>网页时钟</title> </head>
<body onload="startTime()">
<script type="text/javascript">
function displayTime(){
var nowTime=new Date();
var strTime=nowTime.toLocaleString();
var timeDiv=document.getElementsById("timeDiv");
timeDiv.innerHTML=strTime;
}
function startTime(){
window.setInterval("displayTime()",1000);
}
</script>
<div id="timeDiv"></div> </body> </html>