状态栏显示时间代码

<html>
<head>
<title>网页特效|Linkweb.cn/Js|---状态栏滚动时间</title>
</head><body>请看状态栏<BR>
<!--将以下代码加入HTML的<Body></Body>之间-->

<SCRIPT language=JavaScript>
var osd = "   "
osd +="";
var timer;
var msg = "";
function scrollMaster () {
msg = customDateSpring(new Date())
clearTimeout(timer)
msg += " " + showtime() + " " + osd
for (var i= 0; i < 100; i++){
msg = " " + msg;
}
scrollMe()
}
function scrollMe(){
window.status = msg;
msg = msg.substring(1, msg.length) + msg.substring(0,1);
timer = setTimeout("scrollMe()", 200);
}
function showtime (){
var now = new Date();
var hours= now.getHours();
var minutes= now.getMinutes();
var seconds= now.getSeconds();
var months= now.getMonth();
var dates= now.getDate();
var years= now.getYear();
var timeValue = ""
timeValue += ((months >9) ? "" : " ")
timeValue += ((dates >9) ? "" : " ")
timeValue = ( months +1)
timeValue +="/"+ dates
timeValue +="/"+  years
var ap="A.M."
if (hours == 12) {
ap = "P.M."
}
if (hours == 0) {
hours = 12
}
if(hours >= 13){
hours -= 12;
ap="P.M."
}
var timeValue2 = " " + hours
timeValue2 += ((minutes < 10) ? ":0":":") + minutes + " " + ap
return timeValue2;
}
function MakeArray(n) {
this.length = n
return this
}
monthNames = new MakeArray(12)
monthNames[1] = "一月"
monthNames[2] = "二月"
monthNames[3] = "三月"
monthNames[4] = "四月"
monthNames[5] = "五月"
monthNames[6] = "六月"
monthNames[7] = "七月"
monthNames[8] = "八月"
monthNames[9] = "九月"
monthNames[10] = "十月"
monthNames[11] = "十一月"
monthNames[12] = "十二月"
daysNames = new MakeArray(7)
daysNames[1] = "周日"
daysNames[2] = "周一"
daysNames[3] = "周二"
daysNames[4] = "周三"
daysNames[5] = "周四"
daysNames[6] = "周五"
daysNames[7] = "周六"
function customDateSpring(oneDate) {
var theDay = daysNames[oneDate.getDay() +1]
var theDate =oneDate.getDate()
var theMonth = monthNames[oneDate.getMonth() +1]
var dayth="号"
if ((theDate == 1) || (theDate == 21) || (theDate == 31)) {
dayth="st";
}
if ((theDate == 2) || (theDate ==22)) {
dayth="nd";
}
if ((theDate== 3) || (theDate  == 23)) {
dayth="rd";
}
return theDay + ", " + theMonth + " " + theDate + dayth + ","
}
scrollMaster();
</SCRIPT>
</body></html>

posted on 2007-06-30 15:58 ms_dos 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/nine425/archive/2007/06/30/801411.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值