中文(简体)
<!-- 把如下代码加入<head>区域中 --> <style type="text/css"> <!-- span.label {color:black;width:30;height:16;text-align:中心;边距顶部:0;背景:#ffF;字体:粗体 13px Arial} span.c1 {光标:手;颜色:黑色;宽度:30;高度:16;文本对齐:中心;边距顶部:0 ;背景:#ffF;字体:粗体 13px Arial} span.c2 {光标:手;颜色:红色;宽度:30;高度:16;文本对齐:中心;边距顶部:0;背景:#ffF;字体:bold 13px Arial} span.c3 {光标:hand;color:#b0b0b0;width:30;height:16;text-align:center;margin-top:0;background:#ffF;font:bold 12px Arial} - -> </style> <script type="text/javascript"> //来自 http://www.downcodes.com 的更多 javascript <!-- Begin function maxDays(mm, yyyy){ var mDay; if((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10)){ mDay = 30; } else{ mDay = 31 if(mm == 1){ if (yyyy/4 - parseInt(yyyy/4) != 0){ mDay = 28 } else{ mDay = 29 } } } return mDay; } function changeBg(id){ if (eval(id).style.backgroundColor != "yellow"){ eval(id).style.backgroundColor = "yellow" } else{ eval(id).style.backgroundColor = "# ffffff" } } function writeCalendar(){ var now = new Date var dd = now.getDate() var mm = now.getMonth() var dow = now.getDay() var yyyy = now.getFullYear() var arrM = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月") var arrY = new Array() for (ii=0;ii<=4;ii++){ arrY[ii] = yyyy - 2 + ii } var arrD = new Array("周日","周一","周二", "星期三","星期四","星期五","星期六") var text = "" text = "<表单名称=calForm>" text += "<表格边框=1>" text += "<tr>< td>" 文本 += "<表格宽度=100%><tr>" 文本 += "<tdalign=left>" 文本 += "<select name=selMonth onChange='changeCal()'>" for (ii =0;ii<=11;ii++){ if (ii==mm){ text += "<选项值= " + ii + "选定>" + arrM[ii] + "</选项>" } else{文本 += "<选项值= " + ii + ">" + arrM[ii] + "</选项>" } } 文本 += "</select>" 文本 += "</td>" 文本 += "<tdalign=right>" 文本 += "<select name=selYear onChange='changeCal()'>" for (ii=0;ii<=4;ii++){ if (ii==2){ 文本 + = "<选项值= " + arrY[ii] + " 已选择>" + arrY[ii] + "</选项>" } else{ text += "<选项值= " + arrY[ii] + ">" + arrY[ii] + "</option>" } } 文本 += "</select>" 文本 += "</td>" 文本 += "</tr></table>" 文本 += "< /td></tr>" 文本 += "<tr><td>" 文本 += "<表格边框=1>" 文本 += "<tr>" for (ii=0;ii<=6;ii++ ){ text += "<tdalign=center><span class=label>" + arrD[ii] + "</span></td>" } text += "</tr>" aa = 0 for ( kk=0;kk<=5;kk++){ 文本 += "<tr>" for (ii=0;ii<=6;ii++){ 文本 += "<tdalign=center><span id=sp" + aa + " onClick='changeBg(this.id)'>1</span></td>" aa += 1 } 文本 += "</tr>" } 文本 += "</table>" 文本+=“</td></tr>”文本+=“</table>”文本+=“</form>”document.write(text)changeCal()}functionchangeCal(){varnow=newDate var dd = now.getDate() var mm = now.getMonth() var dow = now.getDay() var yyyy = now.getFullYear() var currM = parseInt(document.calForm.selMonth.value) var prevM if (currM !=0){ prevM = currM - 1 } else{ prevM = 11 } var currY = parseInt(document.calForm.selYear.value) var mmyyyy = new Date() mmyyyy.setFullYear(currY) mmyyyy.setMonth(currM) mmyyyy .setDate(1) var day1 = mmyyyy.getDay() if (day1 == 0){ day1 = 7 } var arrN = new Array(41) var aa for (ii=0;ii<day1;ii++){ arrN[ ii] = maxDays((prevM),currY) - 第 1 天 + ii + 1 } aa = 1 for (ii=第 1 天;ii<=第 1 天 + maxDays(currM,currY)-1;ii++){ arrN[ii] = aa aa += 1 } aa = 1 for (ii=day1+maxDays(currM,currY);ii<=41;ii++){ arrN[ii] = aa aa += 1 } for (ii=0;ii<=41 ;ii++){ eval("sp"+ii).style.backgroundColor = "#FFFFFF" } var dCount = 0 for (ii=0;ii<=41;ii++){ if (((ii<7)&&( arrN[ii]>20))||((ii>27)&&(arrN[ii]<20))){ eval("sp"+ii).innerHTML = arrN[ii] eval("sp"+ii) ).className = "c3" } else{ eval("sp"+ii).innerHTML = arrN[ii] if ((dCount==0)||(dCount==6)){ eval("sp"+ii) ).className = "c2" } else{ eval("sp"+ii).className = "c1" } if ((arrN[ii]==dd)&&(mm==currM)&&(yyyy==currY) ){ eval("sp"+ii).style.backgroundColor="#90EE90" } } dCount += 1 if (dCount>6){ dCount=0 } } } // 结束 --> </script> <! -- 把如下代码加入<body>区域中 --> <script type="text/javascript">writeCalendar()</script>