设为首页 | 加入收藏
当前位置:首页>>网页特效>>网页时间特效>> 状态栏时间跳动特效

状态栏时间跳动特效

时间:2005-1-14 21:41:40 来源:本站收集整理 作者:佚名

要完成此效果需要两个步骤


第一步:把如下代码加入到<body>区域中

<SCRIPT LANGUAGE="JavaScript">
<!--
var flasher = false
// calculate current time, determine flasher state,
// and insert time into status bar every second
function updateTime() {
var now = new Date()
var theHour = now.getHours()
var theMin = now.getMinutes()
var theTime = "" + ((theHour > 12) ? theHour - 12 : theHour)
theTime += ((theMin < 10) ? ":0" : ":") + theMin

theTime += ((flasher) ? "  " : " =")
theTime += (theHour >= 12) ? " 下午" : " 上午"
flasher = !flasher
window.status = theTime
// recursively call this function every second to keep timer going
timerID = setTimeout("updateTime()",1000)
}
//-->
</SCRIPT>


第二步:把“onLoad="updateTime()"”加在<body>标记里
例如:<body onLoad="updateTime()">