Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5404195
  • 博文数量: 763
  • 博客积分: 12108
  • 博客等级: 上将
  • 技术积分: 15717
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-28 21:21
个人简介

业精于勤,荒于嬉

文章分类

全部博文(763)

文章存档

2018年(6)

2017年(15)

2016年(2)

2015年(31)

2014年(14)

2013年(87)

2012年(75)

2011年(94)

2010年(190)

2009年(38)

2008年(183)

2007年(28)

分类: 系统运维

2008-05-22 14:26:06

<script language="JavaScript">

monthnames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","10月","11月","12月");

                                               <!--声明数组变量,存储月份表-->

var linkcount=0;

function addlink(month, day, href)

{

var entry = new Array(3); <!--声明一个数组变量-->

entry[0] = month;

entry[1] = day;

entry[2] = href;

this[linkcount++] = entry; <!--返回链接对象-->

}

Array.prototype.addlink = addlink;

linkdays = new Array();

monthdays = new Array(12); <!--声明变量,存储每个月的天数-->

monthdays[0]=31;

monthdays[1]=28;

……

monthdays[11]=31;

todayDate=new Date(); <!--获得当前时间-->

thisday=todayDate.getDay(); <!--获得当前日子-->

thismonth=todayDate.getMonth(); <!--获得当前月份-->

thisdate=todayDate.getDate(); <!--获得当前日期-->

thisyear=todayDate.getYear(); <!--获得当前年份-->

thisyear = thisyear % 100;

<!--年份转换成标准格式-->

thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));

if (((thisyear % 4 == 0) <!--判断今年是否为闰年-->

<!--如果是不是闰年,monthdays中的第二项+1-->

&& !(thisyear % 100 == 0))

||(thisyear % 400 == 0)) monthdays[1]++;

startspaces=thisdate;

while (startspaces > 7) startspaces-=7; <!--求出当前日期对应星期几-->

startspaces = thisday - startspaces + 1;

if (startspaces < 0) startspaces+=7; <!--计算本月1号对应星期几-->

<!--开始画表格的第一行-->

document.write("

);

document.write("bordercolor=black>");

<!--显示当前年份和月份-->

document.write("
");

document.write("
"); <!--画表格的第二行-->

document.write("
");

document.write("
");

document.write("
");

document.write("
");

document.write("
");

document.write("
");

document.write("
");

document.write("
");

document.write("
");

for (s=0;s<startspaces;s++)

{

document.write("
"); <!--本月1号以前的几列空白-->

}

count=1;

<!--依次将本月的每一天填入到表格中-->

while (count <= monthdays[thismonth])

{

for (b = startspaces;b<7;b++)

{

linktrue=false;

document.write("
");

count++;

}

document.write("
");

document.write("
");

startspaces=0;

}

document.write("
" + thisyear +"年"+monthnames[thismonth]+"
 "); <!--写入表格符-->

for (c=0;c<linkdays.length;c++)

{

if (linkdays[c] != null) <!--填入相应的连接-->

{

if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count))

{

document.write(" + linkdays[c][2] + "\">");

linktrue=true;

}

}

}

if (count==thisdate)

{

<!--如果是当前日期,则用特殊的颜色来显示-->

document.write("");

}

if (count <= monthdays[thismonth]) <!--如果没有超出本月的范围-->

{

document.write(count); <!--显示日期-->

}

else

{

document.write(" "); <!--否则,显示空格-->

}

if (count==thisdate)

{

<!--如果是当前日期,则用特殊的字体来显示-->

document.write("
"
);

}

if (linktrue)

document.write("
");

document.write("

");

阅读(1525) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~