一个比较简捷的日历

Posted on 2006-08-17 09:25  秋雨飘飘  阅读(198)  评论(0编辑  收藏  举报
 1function getlink(action,name,link) {
 2    monthnames = new Array(
 3    "一月",
 4    "二月",
 5    "三月",
 6    "四月",
 7    "五月",
 8    "六月",
 9    "七月",
10    "八月",
11    "九月",
12    "十月",
13    "十一月",
14    "十二月"); 
15    var linkcount=0;
16    linkdays = new Array();
17    monthdays = new Array(12);
18    monthdays[0]=31;
19    monthdays[1]=28;
20    monthdays[2]=31;
21    monthdays[3]=30;
22    monthdays[4]=31;
23    monthdays[5]=30;
24    monthdays[6]=31;
25    monthdays[7]=31;
26    monthdays[8]=30;
27    monthdays[9]=31;
28    monthdays[10]=30;
29    monthdays[11]=31;
30    todayDate=new Date();
31    thisday=todayDate.getDay();
32    thismonth=todayDate.getMonth();
33    thisdate=todayDate.getDate();
34    thisyear=todayDate.getYear();
35    thisyear = thisyear % 100;
36    thisyear = ((thisyear < 50? (2000 + thisyear) : (1900 + thisyear));
37    if (((thisyear % 4 == 0&& !(thisyear % 100 == 0))||(thisyear % 400 == 0)) monthdays[1]++;
38    startspaces=thisdate;
39    while (startspaces > 7) startspaces-=7;
40    startspaces = thisday - startspaces + 1;
41    if (startspaces < 0) startspaces+=7;
42    document.write("<table border=0 cellpadding=2 cellspacing=1");
43    document.write("><font color=black>");
44    document.write("<tr><td colspan=7><center><< " 
45    +"今天是:"+ thisyear 
46    +"年 "+monthnames[thismonth]+" >></center></font></td></tr>");
47    document.write("<tr>");
48    document.write("<td align=center>日</td>");
49    document.write("<td align=center>一</td>");
50    document.write("<td align=center>二</td>");
51    document.write("<td align=center>三</td>");
52    document.write("<td align=center>四</td>");
53    document.write("<td align=center>五</td>");
54    document.write("<td align=center>六</td>"); 
55    document.write("</tr>");
56    document.write("<tr>");
57    for (s=0;s<startspaces;s++{
58        document.write("<td>&nbsp</td>");
59    }

60    count=1;
61    while (count <= monthdays[thismonth]) {
62        for (b = startspaces;b<7;b++{
63            document.write("<td");
64            if (count==thisdate) {
65                document.write(" bgcolor=red");
66            }

67            document.write(">");
68            if (count <= monthdays[thismonth]) {
69                document.write("<a href='" + action + ".asp?ChannelID=" + name + "&AuthorName=" + link + "&Data=" + thisyear + "-" + (thismonth + 1+"-"+ count + "'>" + count + "</a>" );
70            }

71            else {
72                document.write("&nbsp");
73            }

74            document.write("</td>");
75            count++;
76        }

77        document.write("</tr>");
78        document.write("<tr>");
79        startspaces=0;
80    }

81    document.write("</tr></table>");
82}

Copyright © 2024 秋雨飘飘
Powered by .NET 8.0 on Kubernetes