網頁時鐘
阿新 • • 發佈:2018-02-05
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>
網頁時鐘