發新話題

《JavaSCript 範例》文字時鐘

《JavaSCript 範例》文字時鐘

加入網頁步驟   
1.將以下的控制碼先複製起來。(用滑鼠將底下的一堆碼,標記起來,按滑鼠右鍵選擇【複製】就行啦!)
2.先將<BODY>先拿掉
3.然後在網頁中的 </HEAD> 之後將剛剛複製的東西貼上就大功告成了  !(按滑鼠右鍵選擇【貼上】就行啦!)


[code<script language="JavaScript1.2">
<!--
document.write('<ilayer id="clockmain" height=20><layer id="clock" width="100%"></layer></ilayer>');
else
document.write("<div><span id='clock'></span></div>");
var now,hours,minutes,seconds,timeValue;
function showtime(){
if (!document.layers&&!document.all) return;
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? "下午 " : "上午 ";
timeValue += ((hours > 12) ? hours - 12 : hours) + " 點";
timeValue += ((minutes < 10) ? " 0" : " ") + minutes + " 分";
timeValue += ((seconds < 10) ? " 0" : " ") + seconds + " 秒";
if (document.layers){
document.clockmain.document.clock.document.write(timeValue);
document.clockmain.document.clock.document.close();
}
else if (document.all)
clock.innerHTML = timeValue;
setTimeout("showtime()",100);
}
window.onload=showtime;
//-->
</script>[/code]

[ 本帖最後由 蔡逸竹 於 2006-12-11 23:26 編輯 ]

TOP

發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。