效果图:CSS代: 复制代代码如下: <br>*{ <br>マージン:0; <br>パディング:0; <br>フォント:10px タホマ; <br>} <br>#calender{ <br>text-align:center; <br>幅:147ピクセル; <br>フォントサイズ:10px; <br>/*color: #27B0C1;*/ <br>margin:12px 0 12px 6px; <br>ボーダートップ:1px ソリッド #EEEEEE; <br>ボーダー左:1px 実線 #EEEEEE; <br>} <br>#calender .arrow_over{ <br>色: #FF1493; <br>} <br>#calender .arrow_out{ <br>色: #FF8C00; <br>} <br>#calender td{ <br>border-bottom:1px ソリッド #EEEEEE; <br>border-right:1px 実線 #EEEEEE; <br>幅:21px; <br>高さ:20px; <br>行の高さ:16px; <br>色:#666666; <br>} <br>#calender #cal_title{ <br>width:147px;背景:#EFEFEF; <br>} <br>#calender #week td{ <br>背景: #F8F8F8; <br>} <br>#calender .current{ <br>背景: #AAE7E8; <br>表示: ブロック; <br>マージン:2px; <br>} <br>#calender .notcurrent{ <br>表示: ブロック; <br>マージン:2px; <br>背景:#EDEDED; <br>} <br> 脚本代: 复制代 代码如下: <br><!-- <BR>document.writeln("<div id='calenderdiv' style>日历加载中...</div>"); <br>var press_tag; <br>function changecal(action,year,month) <br>{ <br>var strcal; <br>switch(action) <br>{ <br>case "来月" : <br>if(月==11) <br>{ <br>月 = 1; <br>年 = 年*1 1; <br>月 = 月*1 2; >} <br>strcal = "<span onmouseover="this.className='arrow_over'" onmouseout="this.className='arrow_out'" class='arrow_out' onclick='calender(" year "," month " )' title='下一个月' style='cursor:hand;'>> </span>"; <br>break; <br>case "premonth": <br>if(month==0) <br>{ <br>month = 12; <br>year = year*1 - 1; <br>} <br>strcal = "<span onmouseover="this.className='arrow_over'" onmouseout="this.className='arrow_out'" class='arrow_out' onclick='calender(" year " ," month ")' title='上一月' style='cursor:hand;'> <</span>"; <br>break; <br>case "nextyear": <br>year = year*1 1; <br>month = month*1 1; <br>strcal = "<スパン onmouseover="this.className='arrow_over'" onmouseout="this.className='arrow_out'" class='arrow_out' onclick='calender(" year "," month ")' title='下一年' style ='cursor:hand;'>>></span>"; <br>break; <br>case "preyear": <br>年 = 年*1 - 1; <br>月 = 月*1 1; <br>strcal = "<span onmouseover="this.className='arrow_over'" onmouseout="this.className='arrow_out'" class='arrow_out' onclick='calender(" year "," month ")' title='上一年' style='cursor:hand;'<<</span>"; <br>default:; strcal = " " strcal " "; <br>return(strcal); <br>関数 calender(cyear,cmonth) <br>{ <br>var d,d_date,d_day,d_month; /定义每月天数组 <br>var monthdates = ["31","28","31","30","31","30","31","31","30"," 31","30","31"] <br>d = new Date(); <br>d_year = d.get Year(); //获取年份 <br>// 判断闰月、把月日付の二月改成29 <br>if (((d_year % 4 == 0) && (d_year % 100 != 0)) || (d_year % 400 == 0)) monthdates[1] = "29"; <br>if ((cyear != "" ) || (cmonth != "")) <br>{ <br>//如果用户选择了月份和年份,则当前の時間変更は用户設定 <br>d.setyear(cyear); <br>d.setMonth(cmonth-1); <br>d.setDate(1); <br>} <br>d_month = d.getMonth(); //获取当前是第几个月 <br>d_year = d.get Year(); //获取年份 <br>d_date = d.getDate(); //获取日期 <br>//修正19XX年只显表示二位の错误 <br>if(d_year//===========输出日历=========== <br>var str; <br>str = "<table cellpacing='0' cellpadding='0' id='calender'>"; <br>str = "<tr><td id='cal_title'colspan='7' >" <br>str =changecal("前年",d_年,d_月) <br>str =changecal("前月",d_年,d_月) <br>str = d_年 " - " (d_月*1 1) <br>str = changecal("nextmonth",d_year,d_month) <br>str = changecal("nextyear",d_year,d_month) <br>str = "</td></tr>"; <br>str = "<tr id='week'><td>Su</td><td>Mo</td><td>Tu</td><td>We</ td><td>Th</td> <td>Fr</td> <td>Sa</td> <tr>"; <br>str = "</tr> <tr>"; <br>var firstday、lastday、totalcounts、firstspace、lastspace、monthdays; <br>// 必要な月份共有几天、既定の数集合を使用して取得できます <br>monthdays = monthdates[d.getMonth()]; <br>//設定日期は月份中の第一天 <br>d.setDate(1); <br>// 必要な月份の第一天は星期几 <br>firstday = d.getDay(); <br>//1 号の先頭に必要な空の元格の数 <br>firstspace = firstday; <br>//設定日期は月份の最後の一天 <br>d.setDate(monthdays); <br>// 必要な月份の最後の一天は星期几 <br>lastday = d.getDay(); <br>//最終一天后面必要空单元格数 <br>lastspace = 6 - lastday; <br>//前空单元格 总天数 後空单元格,用来制御循環环 <br>totalcounts = firstspace*1 monthdays*1 lastspace*1; <br>//count:大循環量;f_space:出力前空元格の循環量;l_space:出力後空元格の循環量<br>var count,flag,f_space,l_space; <br>//flag:前空单元格输完后令flag=1不再继续做这个小循環环 <br>flag = 0; <br>for(count=1;count<=totalcounts;count ) <br>{ <br>//一开開始flag=0,首先输出前空单元格,输完到後flag=1,以後不再実行この循環 <br>if(flag==0) <br>{ <br>if(firstspace!=0) <br>{ <br>for(f_space=1;f_space<=firstspace;f_space ) <br>{ <br>str = "<td> </td>"; <br>if(f_space!= firstspace) カウント ; <br>} <br>フラグ = 1; <br>続き; <br>} <br>}<br>if((count-firstspace)<=monthdays) <br>{ <br>//月内のすべての日を出力します<br>curday = d_year "," (d_month*1 1) "," ( count - firstspace) "|" <br>linkday = d_year "," (d_month*1 1) "," (count - firstspace) <br>var today = new Date() <br>if( (d_year ==) today .get Year()) && (d_month == today.getMonth()) && ((count-firstspace) == today.getDate()) ) <br>{ <br>// の現在の日数を強調表示します。ローカル システム <br>str = "<td><span class='current'>" (count - firstspace) "<br>}else{ <br> // ハイライト部分なし、ログなし<br>str = "<td>" (count - firstspace) "</td>"; <br>} <br>if(count%7==0) <br>{ <br>if(count<totalcounts) <br>{ <br>str = "</tr><tr>"; <br>}else{ <br>str = "</tr>" ; <br>} <br>} <br>}else{ <br>//月の最終日が出力されている場合は、出力を開始し、空のセルを埋めます <br>for(l_space=1;l_space<= lastspace;l_space ) <br>{ <br>str = "<td> </td>"; <br>if(l_space!= lastspace) <br>} <br>} <br>} <br>str = "<tr><tdcolspan='7' style='text-indent:9px;'><a href='http://www.jb51.net' title='ウェブサイトのデザイン'>www.sugood.cn</a></td></tr></table>" <br>document.getElementById("calenderdiv").innerHTML = "< div id='calenderdiv'>" str "</div>"; <br>} <br>//関数呼び出し <br>calender("","") <br>//--> <br>