热烈祝贺台州朗动科技的站长论坛隆重上线!(2012-05-28)    热烈庆祝伟大的祖国60周年生日 点击进来我们一起为她祝福吧(2009-09-26)    站长论坛禁止发布广告,一经发现立即删除。谢谢各位合作!.(2009-08-08)    热烈祝贺台州网址导航全面升级,全新版本上线!希望各位一如既往地支持台州网址导航的发展.(2009-03-28)    台州站长论坛恭祝各位新年快乐,牛年行大运!(2009-01-24)    台州Link正式更名为台州网址导航,专业做以台州网址为主的网址导航!(2008-05-23)    热烈祝贺台州Link资讯改名为中国站长资讯!希望在以后日子里得到大家的大力支持和帮助!(2008-04-10)    热烈祝贺台州Link论坛改名为台州站长论坛!希望大家继续支持和鼓励!(2008-04-10)    台州站长论坛原[社会琐碎]版块更名为[生活百科]版块!(2007-09-05)    特此通知:新台州站长论坛的数据信息全部升级成功!">特此通知:新台州站长论坛的数据信息全部升级成功!(2007-09-01)    台州站长论坛对未通过验证的会员进行合理的清除,请您谅解(2007-08-30)    台州网址导航|上网导航诚邀世界各地的网站友情链接和友谊联盟,共同引领网站导航、前进!(2007-08-30)    禁止发广告之类的帖,已发现立即删除!(2007-08-30)    希望各位上传与下载有用资源和最新信息(2007-08-30)    热烈祝贺台州站长论坛全面升级成功,全新上线!(2007-08-30)    
便民网址导航,轻松网上冲浪。
台州维博网络专业开发网站门户平台系统
您当前的位置: 首页 » JavaScript/JQuery编程 » 动态时钟的举例

动态时钟的举例

论坛链接
  • 动态时钟的举例
  • 发布时间:2007-10-05 21:11:36    浏览数:5753    发布者:superadmin    设置字体【   
#######################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>
娱乐休闲专区A 影视预告B 音乐咖啡C 英语阶梯D 生活百科
网页编程专区E AMPZF HTMLG CSSH JSI ASPJ PHPK JSPL MySQLM AJAX
Linux技术区 N 系统管理O 服务器架设P 网络/硬件Q 编程序开发R 内核/嵌入
管理中心专区S 发布网址T 版主议事U 事务处理