不錯的javascript 日曆代碼

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<html><head><title>非常棒的灰色日曆代碼 </title></head><body><style type="text/css">.body,td{font-family:"Arial";font-size:8pt;color:#000000;}.TrOut{background:#dddddd;height:24;border:1 solid #999999;border-top-color:#f4f4f4;border-left-color:#f4f4f4;}.TdOver{background:#eeeeee;height:20;border:1 solid #ffffff;border-top-color:#9c9c9c;border-left-color:#9c9c9c;}.TdOut{background:#eeeeee;height:20;border:1 solid #9c9c9c;border-top-color:#ffffff;border-left-color:#ffffff;}</style><script language="JScript">function TableFunction(){ this.GetDataStr=function(y,m){ this.DayArray=[]; for(var i=0;i<42;i++)this.DayArray[i]=" "; for(var i=0;i<new Date(y,m,0).getDate();i++)this.DayArray[i+new Date(y,m-1,1).getDay()]=i+1; return this.DayArray; } this.GetTableStr=function(y,m){ this.DateArray=["日","一","二","三","四","五","六"]; this.DStr="<table oncontextmenu='return false' onselectstart='return false' border='0' cellpadding='0' cellspacing='0'>n"+ "<tr><td colspan='7' class='TrOut'>"+ "<table width='100%' height='100%'border='0' cellpadding='0' cellspacing='0'><tr align='center'>n"+ "<td width='20' webdings";font-size:9pt' onclick='TableFunction().JumpToRun("b")' onmouseover='this.style.color="#ff9900"' onmouseout='this.style.color=""'>3</td>n"+ "<td id='YearTD' width='70' onmouseover='this.style.background="#cccccc"' onmouseout='this.style.background=""' onclick='TableFunction().WriteSelect(this,this.innerText.split(" ")[0],"y",false)'>"+y+" 年</td>n"+ "<td id='MonthTD' width='47' onmouseover='this.style.background="#cccccc"' onmouseout='this.style.background=""' onclick='TableFunction().WriteSelect(this,this.innerText.split(" ")[0],"m",false)'>"+m+" 月</td>n"+ "<td width='20' webdings";font-size:9pt' onclick='TableFunction().JumpToRun("n")' onmouseover='this.style.color="#ff9900"' onmouseout='this.style.color=""'>4</td></tr></table>n"+ "</td></tr>n"+ "<tr align='center'>n"; for(var i=0;i<7;i++) this.DStr+="<td class='TrOut'>"+DateArray[i]+"</td>n"; this.DStr+="</tr>n"; for(var i=0;i<6;i++){ this.DStr+="<tr align='center'>n"; for(var j=0;j<7;j++){ var CS=new Date().getDate()==this.GetDataStr(y,m)[i*7+j]?"TdOver":"TdOut"; this.DStr+="<td id='TD' class='"+CS+"' cs='"+CS+"' onmouseover='this.className="TdOver"' onmouseout='if(this.cs!="TdOver")this.className="TdOut"'>"+this.GetDataStr(y,m)[i*7+j]+"</td>n"; } this.DStr+="</tr>n"; } this.DStr+="</tabe>"; return this.DStr; } this.WriteSelect=function(obj,values,action,getobj){ if(values=="")return; if(getobj){ obj.innerHTML=values+(action=="y"?" 年":" 月"); this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]); return false; } var StrArray=[]; if(action=="y"){ for(var i=0;i<15;i++){ var year=values-7+i; StrArray[i]="<option value='"+year+"' "+(values==year?"selected":"")+"> "+year+"年</option>n"; } obj.innerHTML="<select id='select1' onchange='TableFunction().WriteSelect(parentElement,this.value,"y",true)' onblur='YearTD.innerText=this.value+" 年"'>n"+StrArray.join("")+"</select>"; select1.focus(); } if(action=="m"){ for(var i=1;i<13;i++) StrArray[i]="<option value='"+i+"' "+(i==values?"selected":"")+"> "+i+"月</option>n"; obj.innerHTML="<select id='select2' onchange='TableFunction().WriteSelect(parentElement,this.value,"m",true)' onblur='MonthTD.innerText=this.value+" 月"'>n"+StrArray.join("")+"</select>"; select2.focus(); } } this.RewriteTableStr=function(y,m){ var TArray=this.GetDataStr(y,m); for(var i=0;i<TArray.length;i++){ TD[i].innerHTML=TArray[i]; TD[i].className="TdOut"; TD[i].cs="TdOut"; if(new Date().getYear()==y&&new Date().getMonth()+1==m&&TArray[i]==new Date().getDate()){ TD[i].className="TdOver"; TD[i].cs="TdOver"; } } } this.JumpToRun=function(action){ var YearNO=YearTD.innerText.split(' ')[0]; var MonthNO=MonthTD.innerText.split(' ')[0]; if(action=="b"){ if(MonthNO=="1"){ MonthNO=13; YearNO=YearNO-1; } MonthTD.innerText=MonthNO-1+" 月"; YearTD.innerText=YearNO+" 年"; this.RewriteTableStr(YearNO,MonthNO-1); } if(action=="n"){ if(MonthNO=="12"){ MonthNO=0; YearNO=YearNO-(-1); } YearTD.innerText=YearNO+" 年"; MonthTD.innerText=MonthNO-(-1)+" 月"; this.RewriteTableStr(YearNO,MonthNO-(-1)); } } return this; }document.write(TableFunction().GetTableStr(new Date().getYear(),new Date().getMonth()+1));</script><br /><br /><br /></body></html></td> </tr></table>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.