查看: 5698|回复: 0
打印 上一主题 下一主题

动态时钟的举例

[复制链接]
跳转到指定楼层
1#
发表于 2007-10-5 21:11:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
#######################JS代码#########################################
function Year_Month(){
    var now = new Date();
    var yy = now.getYear();
    var mm = now.getMonth()+1;
    var cl = '<font color="#000000">';
    if (now.getDay() == 0) cl = '<font color="#c00000">';
    if (now.getDay() == 6) cl = '<font color="#00c000">';
    return(cl +'<font color="#FF7311">'+yy+'</font>'+ '<font color="000000">年</font>'+'<font color="#FF7311">'+mm+'</font>'+'<font color="000000">月</font>');
}


function Date_of_Today(){
    var now = new Date();
    var cl = '<font color="#000000">';
    if (now.getDay() == 0) cl = '<font color="#c00000">';
    if (now.getDay() == 6) cl = '<font color="#00c000">';
    return(cl + '<font color="#FF7311">'+now.getDate()+'</font>'+ '<font color="000000">日</font>');
}

function Day_of_Today(){
    var day = new Array();
    day[0] = "<font color=000000>星期</font><font color=#FF7311>日</font>";
    day[1] = "<font color=000000>星期</font><font color=#FF7311>一</font>";
    day[2] = "<font color=000000>星期</font><font color=#FF7311>二</font>";
    day[3] = "<font color=000000>星期</font><font color=#FF7311>三</font>";
    day[4] = "<font color=000000>星期</font><font color=#FF7311>四</font>";
    day[5] = "<font color=000000>星期</font><font color=#FF7311>五</font>";
    day[6] = "<font color=000000>星期</font><font color=#FF7311>六</font>";
    var now = new Date();
    var cl = '<font color="#000000">';
    if (now.getDay() == 0) cl = '<font color="#c00000">';
    if (now.getDay() == 6) cl = '<font color="#00c000">';
    return(cl +  day[now.getDay()] + '</font>');
}

function CurentTime(){
    var now = new Date();
    var hh = now.getHours();
    var mm = now.getMinutes();
    var ss = now.getTime() % 60000;
    ss = (ss - (ss % 1000)) / 1000;
    var clock = hh+':';
    if (mm < 10) clock += '0';
    clock += mm+':';
    if (ss < 10) clock += '0';
    clock += ss;
    return(clock);
}

function refreshCalendarClock(){
document.all.calendarClock1.innerHTML = Year_Month();
document.all.calendarClock2.innerHTML = Date_of_Today();
document.all.calendarClock3.innerHTML = Day_of_Today();
document.all.calendarClock4.innerHTML = CurentTime();
}

setInterval('refreshCalendarClock()',1000);

#######################以下是HTML代码引用上面的JS代码###########################

<tr bgcolor=#FEFEEF><td align="center" width="100%" height="100%">
<font id="calendarClock1" style="font-family:宋体;font-size:15px;color:red;"></font>
<!--<font id="calendarClock1" style="font-family:Arial;font-size:15px;color:red;font-weight:bold"></font>-->
<font id="calendarClock2" style="font-family:宋体;font-size:15px;color:red;"> </font><br>
<font id="calendarClock3" style="font-family:宋体;font-size:13px;"> </font><br>
<font id="calendarClock4" style="color:#100080;font-family:Arial;font-size:12px;"></font>
</td></tr>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表