Tip: You can modify some of the code before running
<title>javascript Calendar </title> <table cellpadding= "0" cellspacing= "0" id= "1" > <tr> <TD>&L T;style> body,td,.p1,.p2,.i{font-family:arial} body{margin:6px 0 0 0;background-color: #fff; color: #000;} table{border:0} #cal {width:434px;border:1px solid #c3d9ff; font-size:12px;margin:8px 0 0 15px} #cal #top {height:29px; Line-height:29px;background: #e7eef8 color: #003784;p adding-left:70px} #cal #top select{font-size:12px} #cal #top input{padding:0} #cal ul#wk{margin:0;padding:0;height:25px} #cal ul#wk li{float:left;width:60px;text-align:center; Line-height:25px;list-style:none} #cal ul#wk li b{font-weight:normal;color: #c60b02} #cal #cm {clear:left;border-top : 1px solid #ddd border-bottom:1px dotted #ddd;p osition:relative} #cal #cm. cell{position:absolute;width:42px;height : 36px;text-align:center;margin:0 0 0 9px} #cal #cm. cell. so{font:bold 16px Arial; #cal #bm {text-align:right;height:24px;line-height:24px;padding:0 13px 0 0} #cal #bm a{color:7977ce} #Cal #fd {display:none;position:absolute;border:1px solid #dddddf; background: #feffcd;p adding:10px;line-height:21px; width:150px} #cal #fd b{font-weight:normal;color: #c60a00} </style> <!--[if ie]> <style> #cal #top {p ADDING-TOP:4PX} #cal #top input{width:65px} #cal #fd {width:170px} </style> <! [endif]--> <div id= "cal" > <div id= "Top" > A.D. <select> </select> year <sel ect> </select> Month lunar calendar <span></span> year [ <span>< /SPAN> year ] <input type= "button" value= "Back to Today" title= "click Back Today" > </div> <ul id= "wk" > <li> one </li> <li> two </li> <li> three </li> <li> four < /li> <li> five </li> <li><b> six </b></li> <li><b> Day </b></li > </ul> <div id= "cm" ></div> <div id= "BM" ></div> </div></td> </tr> </table> <script type= "Text/javascript" > <!--(function () {var S=navi Gator.userAgent.indexOf ("MSIE")!=-1&&!window.opera; function M (c) {return document.getElementById (c)} function R (c) {return document.createelement (c)} var p=[19416,1916 8,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,4216 0,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,12 0998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43 856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18 864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,556 36,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,11896 6,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448]; var k= "A B-n-butyl Xing"; var j= "Kaniko Chen has not Shin Hai"; var o= "Mouse cow tiger rabbit snake horse sheep monkey chicken Dog pig"; var l=["Xiaohan", "Dahan", "Spring", "Rain", "insects", "vernal Equinox", "Qingming", "" Rain "," Summer "," Xiaoman "," grain "," Summer solstice "," slight heat "," Great Heat "," the beginning of the autumn "," Chushu "," Lu "," Autumnal Equinox "," Dew "," Frost "," Winter " , "Snow", "Snow", "Winter Solstice"]; var d=[ 0,21208,43467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,3974 47,419210,440795,462224,483532,504758]; var b= "Day 1,234,567,890"; var h=["Zheng", "two", "three", "four", "five", "six", "seven", "eight", "Nine", "Ten", "11", "Wax"]; var e= "the first 33"; var v={"0101": "*1 New Year's Day", "0214": "Valentine's Day", "0305": "Learn Lei Feng Anniversary", "0308": "Women's Day", "0312": "Arbor Tree", "0315": "Consumer Equity Days", "0401": "April Fools", "0501 ":" *1 Labor Day "," 0504 ":" "Youth Day", "0601": "International Children", "0701": "The Birth of China ___", "0801": "Army", "0910": "China Teachers '," "1001": "*3 National holiday", "1224": " Christmas Eve "," 1225 ":" Xmas "}; var t={"0101": "*2 Spring Festival", "0115": "Lantern Festival", "0505": "*1 Dragon Boat Festival", "0815": "*1 Mid-Autumn Festival", "0909": "Chung Yeung Festival", "1208": "WaxEight "," 0100 ":" New Year's Eve "}; function U (Y) {function C (j,i) {var h=new Date (31556925974.7* (j-1900) +d[i]*60000) +DATE.UTC (1900,0,6,2,5)); Return (H.getutcdate ())} function d (k) {var h,j=348; for (h=32768;h>8;h>>=1) {j+= (p[k-1900]&h). 1:0} return (J+b (k))} function A (h) {return (K.charat (h%10) +j.c Harat (h%12)} function B (h) {if (g (h)) {return ((p[h-1900]&65536)? 30:29)} else{return (0)}} function g (h) {R Eturn (P[H-1900]&15)} function e (i,h) {return ((p[i-1900]& (65536>>h))? 30:29)} function C (m) {var k,j=0,h = 0; var l=new Date (1900,0,31); var n= (m-l)/86400000; this.daycyl=n+40; this.moncyl=14; for (k=1900;k<2050&&n>0;k++) {h=d (k); N-=h; THIS.MONCYL+=12} if (n<0) {n+=h; k--; THIS.MONCYL-=12} this.year=k; this.yearcyl=k-1864; J=g (k); This.isleap=false; for (k=1;k<13&&n>0;k++) {if (j>0&&k== (j+1) &&this.isleap==false) {--k; This.isleap=true; H=b (this.year)} else{h=e (this.year,k) } if (this.isleap==true&&k== (j+1)) {this.isleap=false} n-=h; if (this.isleap==false) {this.moncyl++}} if (n==0&&j>0&&k==j+1) {if (this.isleap) {This.isLeap=fal SE} else{this.isleap=true; --k; --this.moncyl}} if (n<0) {n+=h; --k; --this.moncyl} this.month=k; This.day=n+1} function G (h) {return h<10? 0 "+h:h} function f (i,j) {var h=i; Return J.replace (/dd?d?d?| Mm? M? m?| Yy?y?y?/g,function (k) {switch (k) {case "yyyy": var l= "+h.getfullyear" (); Return l.substring (l.length-4); Case "DD": Return G (H.getdate ()); Case "D": Return H.getdate (). toString (); Case "MM": Return G ((H.getmonth () +1)); Case "M": Return H.getmonth () +1}})} function Z (i,h) {var J; Switch (i,h) {case 10:j= "decade"; Break Case 20:j= "20"; Break Case 30:j= "30"; Break Default:j=e.charat (Math.floor (H/10)); J+=b.charat (H%10)} return (j)} This.date=y; This.istoday=false; This.isrestday=false; This.solaryear=f (Y, "yyyy"); This.solarmonth=f (Y, "M"); This.sOlardate=f (Y, "D"); This.solarweekday=y.getday (); This.solarweekdayinchinese= "Week" +b.charat (This.solarweekday); var x=new C (Y); This.lunaryear=x.year; This.shengxiao=o.charat ((this.lunaryear-4)%12); This.lunarmonth=x.month; This.lunarisleapmonth=x.isleap; This.lunarmonthinchinese=this.lunarisleapmonth? " Leap "+h[x.month-1]:h[x.month-1]; This.lunardate=x.day; This.showinlunar=this.lunardateinchinese=z (this.lunarmonth,this.lunardate); if (this.lunardate==1) {this.showinlunar=this.lunarmonthinchinese+ "month"} this.ganzhiyear=a (X.yearCyl); This.ganzhimonth=a (x.moncyl); This.ganzhidate=a (x.daycyl++); This.jieqi= ""; this.restdays=0; if (C (This.solaryear, (this.solarmonth-1) *2) ==f (Y, "D")) {this.showinlunar=this.jieqi=l[(this.solarmonth-1) *2]} if ( C (This.solaryear, (this.solarmonth-1) *2+1) ==f (Y, "D")) {this.showinlunar=this.jieqi=l[(this.solarmonth-1) *2+1]} if (this.showinlunar== "Qingming") {this.showinlunar= "Qingming Festival"; This.restdays=1} this.solarfestival=v[f (Y, "MM") +f (y, "DD")]; if (typeof This.solarfestival== "undefined") {this.solarfestival= ""} else{if (/* (d)/.test (This.solarfestival)) {this.restdays= parseint (regexp.$1); This.solarfestival=this.solarfestival.replace (/*d/, "")}} this.showinlunar= (this.solarfestival== "")? This.showInLunar:this.solarFestival; This.lunarfestival=t[this.lunarisleapmonth? " ": G (This.lunarmonth) +g (this.lunardate)]; if (typeof this.lunarfestival== "undefined") {this.lunarfestival= "} else{if (/* (d)/.test (This.lunarfestival)) { This.restdays= (This.restdays>parseint (regexp.$1)) this.restDays:parseInt (regexp.$1); This.lunarfestival=this.lunarfestival.replace (/*d/, "")}} if (This.lunarmonth==12&&this.lunardate==e ( this.lunaryear,12)) {this.lunarfestival=t["0100"]; This.restdays=1} this.showinlunar= (this.lunarfestival== "")? This.showInLunar:this.lunarFestival; This.showinlunar= (this.showinlunar.length>4) this.showInLunar.substr (0,2) + "...": This.showinlunar} var q= ( function () {var x={}; x.lines=0; X.datearray=new ARray (42); function Y (a) {return ((a%4===0) && (a%100!==0)) | | (a%400===0)) } function G (a,b) {return[31, (Y (a)? 29:28), 31,30,31,30,31,31,30,31,30,31][b]} function C (a,b) {a.setdate () + b); Return a} function Z (a) {var f=0; var c=new U (New Date (a.solaryear,a.solarmonth-1,1)); var d= (c.solarweekday-1==-1) 6:c.solarweekday-1; X.lines=math.ceil ((D+g (a.solaryear,a.solarmonth-1))/7); for (Var e=0;e<x.datearray.length;e++) {if (c.restdays!=0) {f=c.restdays} if (f>0) {c.isrest=true} if (d-->0| | C.solarmonth!=a.solarmonth) {x.datearray[e]=null; Continue} var b=new U (New Date ()); if (c.solaryear==b.solaryear&&c.solarmonth==b.solarmonth&&c.solardate==b.solardate) {c.isToday= true} x.datearray[e]=c; C=new U (C (c.date,1)); f--}} return{init:function (a) {Z (a)}, Getjson:function () {return X}}}) (); var w= (function () {var c=m ("Top"). getElementsByTagName ("select") [0]; var x=m ("Top"). getElementsByTagName ("select") [1]; var g=m("Top"). getElementsByTagName ("SPAN") [0]; var c=m ("Top"). getElementsByTagName ("SPAN") [1]; var y=m ("Top"). getElementsByTagName ("INPUT") [0]; function A (g) {g.innerhtml=g.ganzhiyear; C.innerhtml=g.shengxiao} function B (g) {c[g.solaryear-1901].selected=true; X[g.solarmonth-1].selected=true} function f () {var j=c.value; var G=x.value; var i=new U (New Date (j,g-1,1)); Q.init (i); N.draw (); if (this==c) {i=new U (new Date (j,3,1)); G.innerhtml=i.ganzhiyear; C.innerhtml=i.shengxiao} var h=new U (New Date ()); Y.style.visibility= (j==h.solaryear&&g==h.solarmonth)? " Hidden ":" Visible "} function Z () {var g=new U (New Date ()); A (g); B (g); Q.init (g); N.draw (); Y.style.visibility= "hidden"} function D (k,g) {for (Var j=1901;j<2050;j++) {var h=r ("option"); H.value=j; H.innerhtml=j; if (j==k) {h.selected= "selected"} c.appendchild (h)} for (Var j=1;j<13;j++) {var h=r ("option"); H.value=j; H.innerhtml=j; if (j==g) {h.selected= "selected"} x.appendchild (h)} C. onchange=f; X.ONCHANGE=F} function e (g) {D (g.solaryear,g.solarmonth); G.innerhtml=g.ganzhiyear; C.innerhtml=g.shengxiao; Y.onclick=z; Y.style.visibility= "hidden"} return{init:function (g) {e (g)}, Reset:function (g) {B (g)}}}) (); var n= (function () {function C () {var z=q.getjson (); var C=z.datearray; M ("cm"). style.height=z.lines*38+2+ "px"; M ("cm"). innerhtml= ""; for (Var a=0;a<c.length;a++) {if (C[a]==null) {continue} var x=r ("DIV"); if (c[a].istoday) {x.style.border= "1px solid #a5b9da"; X.style.background= "#c1d9ff"} x.classname= "Cell"; x.style.left= (a%7) *60+ "px"; X.style.top=math.floor (A/7) *38+2+ "px"; var b=r ("DIV"); B.classname= "So"; Http://www.codefans.net b.style.color= (a%7) >4| | c[a].isrest)? " #c60b02 ":" #313131 "; B.innerhtml=c[a].solardate; X.appendchild (b); var y=r ("DIV"); Y.style.color= "#666"; Y.innerhtml=c[a].showinlunar; X.appendchild (Y); X.onmouseover= (function (d) {return function (f) {f.show ({dateindex:d,cell:this})} }) (a); X.onmouseout=function () {f.hide ()}; M ("cm"). AppendChild (X)} var g=r ("DIV"); G.id= "FD"; M ("cm"). appendchild (G); F.init (g)} return{draw:function (g) {C (g)}}) (); var f= (function () {var C; function Y (e,c) {if (arguments.length>1) {var b=/([. *+?^=!:${} () |[] /\])/g,z= "{". Replace (b, "\$1"), d= "}". Replace (b, "\$1"); var a=new RegExp ("#" +z+ "([^" +z+d+ "]+") "+d," G "); if (typeof (c) = = "Object") {return E.replace (a,function (f,h) {var g=c[h]; Return typeof (g) = = "undefined"? "": G})} return e} function g (b) {var a=q.getjson (). Datearray[b.dateindex]; var Z=b.cell; var c= "#{solaryear} year #{solarMonth} month #{solarDate} Day #{solarweekdayinchinese}"; c+= "<br><b> Lunar #{lunarmonthinchinese} month #{lunardateinchinese}</b>"; c+= "<br>#{ganzhiyear} Year #{ganzhimonth} month #{ganzhidate} day"; if (a.solarfestival!= "" | | a.lunarfestival!= "" | | A.jieqi!= "") {c+= ' <br><b>#{lunarfestival} #{solarfestival} #{jieqi}</b> "} c.innerhtml=y (C,a); c.style.top=z.offsettop+z.offsetheight-5+ "px"; c.style.left=z.offsetleft+z.offsetwidth-5+ "px"; c.style.display= "Block"} function X () {c.style.display= "none"} return{show:function (z) {G (z)}, Hide:function () { X ()}, Init:function (Z) {c=z}}) (); var a=new U (New Date ()); if (S) {window.attachevent ("onload", function () {W.reset (A)})} w.init (a); Q.init (A); N.draw (); } )(); --> </script></td> </tr> </table>
Tip: You can modify some of the code before running