学习首页 百科 人生课堂 办公软件 英语学习 操作系统 故事会 编程资料 软件学习 设计
铭瑶网 >> 学习首页 >> 编程 >> 状态栏时间跳动
标题:状态栏时间跳动

【字体: 】 时间:2008-4-11 来源:互联网 作者:study

状态栏时间跳动

要完成此效果需要两个步骤第一步:把如下代码加入到<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()"> 

查看/参与:讨论/评论 相关文章:Javascript