1、时钟
<script>
window.onload = time;
function time(){
var show =document.getElementById("demo");
var a = new Date();
show.innerHTML = a.toLocaleTimeString();
setTimeout(time,1000);
}
</script>
</head>
<body >
<div id="demo" >
</div>
</body>
注意:window.onload = time;后面的time方法不能是window.onload = time();否则报TypeError: show is null错