--js网页计时

  <script language="javascript">
   function Year_Month(){
var now = new Date();
var yy = now.getYear();
var mm = now.getMonth()+1;
var cl = '<font color="black">';
if (now.getDay() == 0) cl = '<font-size:12pt color="black">';
if (now.getDay() == 6) cl = '<font-size:12pt color="black">';
return(cl + yy + '年' + mm + '月</font>');
}

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

function Day_of_Today(){
var day = new Array();
day[0] = "星期日";
day[1] = "星期一";
day[2] = "星期二";
day[3] = "星期三";
day[4] = "星期四";
day[5] = "星期五";
day[6] = "星期六";
var now = new Date();
var cl = '<font color="black">';
if (now.getDay() == 0) cl = '<font color="black">';
if (now.getDay() == 6) cl = '<font color="black">';
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();
}

function getCalendarClockFreeCodeMsg(nn){
if (nn == 'off') CalendarClockFreeCode.style.visibility = 'hidden';
else {
CalendarClockFreeCode.style.visibility = 'visible';
setTimeout("getCalendarClockFreeCodeMsg('off')",1000);
}
}

var webUrl = webUrl;

function calendarClockFreeCode(){
var win = window.open('about:blank','_blank','width=300,height=260,top=0,left=0');
win.document.writeln('<'+'script language="javascript">');
win.document.writeln('var autoClose = setTimeout("window.close()",30000)');
win.document.writeln('</'+'script>');
win.document.writeln('<p align="center"><a style="cursor:hand"');
win.document.writeln(' onclick="clearTimeout(autoClose)">請按此處,否則<br>30秒後后此視窗將自動關閉</a></p>');
win.document.writeln('<p>想在自己的網站上添加帶日曆時鐘的朋友,請將下面的代碼貼到網頁的適當地方就可以了<br>');
win.document.writeln('<textarea rows="4" cols="30">');

win.document.writeln('</textarea></p>');
win.document.writeln('<p align="center"><a style="cursor:hand" onclick="window.close()">');
win.document.writeln('[關閉視窗]</a></p>');
}

document.write('<table border=0 cellpadding=0 cellspacing=0><tr><td><font id="calendarClock1" style="color:#000000;font-family:宋体;font-size:9pt;"></font><font id="calendarClock2" style="color:#000000;font-family:Airal;font-size:9pt;"></font><font id="calendarClock3" style="color:#000000;font-family:宋体;font-size:9pt;"></font><font id="calendarClock4" style="color:#000000;font-family:Airal;font-size:9pt;"></font></td></tr></table>' );
setInterval('refreshCalendarClock()',1000);

  </script>
================
网页中嵌入以上代码可以显示"2009年6月8日星期一21:33:17"式样的时间,自动计时。

posted on 2009-06-10 08:51  simhare  阅读(382)  评论(0)    收藏  举报

导航