您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JS实现浏览器状态栏显示时间的方法

2025/5/19 0:03:35发布19次查看
这篇文章主要介绍了js实现浏览器状态栏显示时间的方法,涉及javascript针对时间及状态栏操作的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下,具体如下:
以前做个人主页的时候,总喜欢把自己的网页搞的很个性,在网上做跑马灯文字,在状态栏显示问候语,或者在状态栏添加时间显示,本代码就是实现了状态栏显示当前时间的物资,火狐没测度,ie下效果完美。
运行效果截图如下:
在线演示地址如下:
http://demo.jb51.net/js/2015/js-status-bar-show-time-demo/
具体代码如下:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head><title>状态栏时间显示</title></head><script language="javascript">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) ? " 下午" : " 上午" window.status = timevalue; timerid = settimeout("showtime()",1000); timerrunning = true;}function startclock () { stopclock(); showtime();}</script><body bgcolor="#336699" topmargin="0" leftmargin="0" onload="startclock()">请看左下角!状态栏有时间显示!</body></html>
以上就是本章的全部内容,更多相关教程请访问javascript视频教程!
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product