JavaScript代碼:在網頁中動態顯示當前日期和時間


<head>
<title>在網頁中動態顯示當前日期和時間</title>
</head>
<body onload="showTime()">
<script language="JavaScript">   
        function showTime(){     
        var thetime=new Date();   //   初始化日期對象 
            document.getElementById( "timeArea").innerText   =   thetime.toLocaleString(); 
            window.setTimeout( "showTime()",1000);   //setTimeout (表達式,延時時間)其中延時時間以豪秒爲單位(1000ms=1s)
       
</script>
<div id="timeArea" align="center">
</div>
</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章