用JavaScript写的小日历程序

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 ayine 的 blog

<script language=javascript>
function year_month(){
    var now = new date();
    var yy = now.getyear();
    var mm = now.getmonth()+1;
    var cl = '<font color="#0000df">';
    if (now.getday() == 0) cl = '<font color="#c00000">';
    if (now.getday() == 6) cl = '<font color="#00c000">';
    return(cl +  yy + '年' + mm + '月</font>'); }
 function date_of_today(){
    var now = new date();
    var cl = '<font color="#ff0000">';
    if (now.getday() == 0) cl = '<font color="#c00000">';
    if (now.getday() == 6) cl = '<font color="#00c000">';
    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="#0000df">';
    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(); }
 var weburl = weburl;
document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td>');
document.write('<table id="calendarclockfreecode" border="0" cellpadding="0" cellspacing="0" width="60" height="70" ');
document.write('style="position:absolute;visibility:hidden" bgcolor="#eeeeee">');
document.write('<tr><td align="center"><font ');
document.write('style="cursor:hand;color:#ff0000;font-family:宋体;font-size:14pt;line-height:120%" ');
if (weburl != 'netflower'){
   document.write('</td></tr><tr><td align="center"><font ');
   document.write('style="cursor:hand;color:#2000ff;font-family:宋体;font-size:9pt;line-height:110%" ');
}
document.write('</td></tr></table>');
document.write('<table border="0" cellpadding="0" cellspacing="0" width="61" bgcolor="#c0c0c0" height="70">');
document.write('<tr><td valign="top" width="100%" height="100%">');
document.write('<table border="1" cellpadding="0" cellspacing="0" width="58" bgcolor="#fefeef" height="67">');
document.write('<tr><td align="center" width="100%" height="100%" >');
document.write('<font id="calendarclock1" style="font-family:宋体;font-size:7pt;line-height:120%"> </font><br>');
document.write('<font id="calendarclock2" style="color:#ff0000;font-family:arial;font-size:14pt;line-height:120%"> </font><br>');
document.write('<font id="calendarclock3" style="font-family:宋体;font-size:9pt;line-height:120%"> </font><br>');
document.write('<font id="calendarclock4" style="color:#100080;font-family:宋体;font-size:8pt;line-height:120%"><b> </b></font>');
document.write('</td></tr></table>');
document.write('</td></tr></table>');
document.write('</td></tr></table>');
setinterval('refreshcalendarclock()',1000);
</script>

本文关键:用JavaScript写的小日历程序
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top