1. 程式人生 > >網頁時鐘

網頁時鐘

start script pos nts scrip inter tar ava elements

<!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>

網頁時鐘