咖啡虫之家
我的日历
友情链接
访问计数
最新评论
获取RSS
我的 Blog:
[javascript]
[asp]
[常识]
[SQL]
[文学]
[Dreamweaver]
[网页设计]
[flash]
[片言碎语]
[php]
[web standard]
全站 Blog:
Javascript时钟
Author:咖啡虫 PublishTime:2005-7-15
1.主要用了setTimeout 和 innerHTML
2.请运行下面代码
<script language="JavaScript"> <!-- var now,hours,minutes,seconds,timeValue; function showtime(){ 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 + " 秒"; clock.innerHTML = timeValue; setTimeout("showtime()",1000); } showtime(); //--> </script> <body onload="showtime();" > <span id='clock'></span>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
分类于:
javascript
Powered by
5DBlog.com