當(dāng)前位置:首頁(yè)文章首頁(yè) IT學(xué)院 IT技術(shù)

狀態(tài)欄上時(shí)鐘的代碼

作者:  來(lái)源:  發(fā)布時(shí)間:2011-5-26 15:25:24  點(diǎn)擊:

本文章提供給大家的是一個(gè)學(xué)習(xí)實(shí)例,關(guān)于如何在狀態(tài)上顯示時(shí)鐘,把下面代碼放進(jìn)<body>中就可運(yùn)行,趕緊來(lái)試下吧。

<BODY onLoad="startclock()">
<SCRIPT LANGUAGE=java script>
<!--
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM." : " AM."
window.status = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock () {
stopclock();
showtime();
}
-->
</SCRIPT>

文章評(píng)論

軟件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z