うまく祝日まで表示できましたが。毎年度を一ページで表示したです。しかし修正したら、全体表示できなくなるので、どこで直すほうがいいですが、今までのコードです(万年カレンダー毎月表示できます)。
<HTML> <HEAD> <TITLE>万年カレンダー</TITLE> <SCRIPT type="text/JavaScript"> <!-- var kabe_sun = "pink"; var kabe_mon = "lightgrey"; var kabe_tue = "lightgrey"; var kabe_wed = "lightgrey"; var kabe_thu = "lightgrey"; var kabe_fri = "lightgrey"; var kabe_sat = "lightblue"; var firstAltMsg = " "; var firstAltYMD = " ";//行事テーブル(フラグ(1:祝日 2:記念日など),月,日,メッセージ)
var gyouji_tbl = new Array(
1, 1, 1, "元旦",
1, 1, 0, "成人の日",
1, 2, 11, "建国記念の日",
1, 4, 29, "みどりの日",
1, 5, 3, "憲法記念日",
1, 5, 4, "国民の休日",
1, 5, 5, "こどもの日",
1, 7, 0, "海の日",
1, 9, 0, "敬老の日",
1, 10, 0, "体育の日",
1, 11, 3, "文化の日",
1, 11, 23, "勤労感謝の日",
1, 12, 23, "天皇誕生日",
2, 12, 24, "クリスマスイブ"
);
var kokuminLastCnt = gyouji_tbl.length / 4;
function calendar(num){
var now = new Date();
var year;
var month;
var date;
var dValue = document.getElementById("dValue");
switch(parseInt(num)){
case 0:
year = now.getFullYear();
month = now.getMonth()+1;
date = now.getDate();
break;
case 1:
var backMDate = new Date(parseInt(dValue.innerHTML) - 24606010001);
if(backMDate.getMonth() == now.getMonth() && backMDate.getFullYear() == now.getFullYear()){
year = now.getFullYear();
month = now.getMonth()+1;
date = now.getDate();
}else{
year = backMDate.getFullYear();
month = backMDate.getMonth() + 1;
date = -1;
}
break;
case 2:
var nextMDate = new Date(parseInt(dValue.innerHTML) + 246060100031);
if(nextMDate.getMonth() == now.getMonth() && nextMDate.getFullYear() == now.getFullYear()){
year = now.getFullYear();
month = now.getMonth()+1;
date = now.getDate();
}else{
year = nextMDate.getFullYear();
month = nextMDate.getMonth() + 1;
date = -1;
}
break;
}
dValue.innerHTML = (new Date(year, month-1, 1)).getTime();
var last_date = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var editMsg;
if(month==2){
if(year%4==0){
if((year%100==0) && (year%400!=0)){
}else{
last_date[1] = 29;
}
}
}
editMsg = "";
editMsg += "<TABLE border=0 cellspacing=3><TR><TD colspan='7' align='center'><B><U><FONT size='-1'>" + year + "年" + month + "月</FONT></B></U></TD></TR>\n";
editMsg += "<TR>" + defTD("日","red",kabe_sun) + defTD("月","black",kabe_mon) + defTD("火","black",kabe_tue) + defTD("水","black",kabe_wed) + defTD("木","black",kabe_thu) + defTD("金","black",kabe_fri) + defTD("土","blue",kabe_sat) + "</TR>\n";
editMsg += "<TR>";
for(dayIndex=0; dayIndex<(new Date(year,month-1,1)).getDay(); dayIndex++){
editMsg += defTD(" ","white","white");
}
//行事テーブル(祝日)の再設定
//成人の日
gyouji_tbl[14+2] = getSyukujituDate(year, 1, 2);
//海の日
gyouji_tbl[74+2] = getSyukujituDate(year, 7, 3);
//敬老の日
gyouji_tbl[84+2] = getSyukujituDate(year, 9, 3);
//体育の日
gyouji_tbl[94+2] = getSyukujituDate(year, 10, 2);
//みどりの日4/29→昭和の日 国民の休日5/4→みどりの日
if(year<=2006){
gyouji_tbl[34+3] = "みどりの日";
gyouji_tbl[54+3] = "国民の休日";
} else {
gyouji_tbl[34+3] = "昭和の日";
gyouji_tbl[54+3] = "みどりの日";
}
//当日と行事が重なる場合の初期設定
if(date != -1){
firstAltMsg = " ";
firstAltYMD = year + "/" + month + "/" + date;
for(var j=0; j<kokuminLastCnt; j++){
if(gyouji_tbl[j4+1] == month && gyouji_tbl[j4+2] == date){
firstAltMsg += gyouji_tbl[j*4+3] + " ";
}
}
}
for(i=1; i<=last_date[month-1]; i++){
if(i!=1 && dayIndex == 0){
editMsg += "<TR>";
}
var kabeColor;
var fontColor;
var altYMD = year + "/" + month + "/" + i;
var altMsg = " ";
//曜日別基本設定
switch(dayIndex){
case 0: fontColor = "red";
kabeColor = kabe_sun; break;
case 1: fontColor = "black";
kabeColor = kabe_mon; break;
case 2: fontColor = "black";
kabeColor = kabe_tue; break;
case 3: fontColor = "black";
kabeColor = kabe_wed; break;
case 4: fontColor = "black";
kabeColor = kabe_thu; break;
case 5: fontColor = "black";
kabeColor = kabe_fri; break;
case 6: fontColor = "blue";
kabeColor = kabe_sat; break;
}
//行事の時
for(var j=0; j<kokuminLastCnt; j++){
if(gyouji_tbl[j4+1] == month && gyouji_tbl[j4+2] == i){
//祝日
if(gyouji_tbl[j4] == 1){
fontColor = "red";
}else{
kabeColor = "lightgreen";
}
altMsg += gyouji_tbl[j4+3] + " ";
}
}
//当日
if(i==date){
fontColor = "darkorange";
}
editMsg += defTD2(i,fontColor,kabeColor,altYMD,altMsg);
if(dayIndex == 6){
editMsg += "</TR>\n";
}
dayIndex++; dayIndex%=7;
}
if(dayIndex!=7){
editMsg += "</TR>\n";
}
editMsg += "</TABLE>\n";
document.getElementById("calendar").innerHTML = editMsg;
}
function defTD(str, iro, kabe){
return "<TD style='cursor:default' align='center' bgcolor='" + kabe + "'><B><FONT size='-2' color='" + iro + "'>" + str + "</FONT></B></TD>";
}
function defTD2(str, iro, kabe, altYMD,altMsg){
return "<TD style='cursor:default' align='center' bgcolor='" + kabe + "' onMouseOver=setAltMsg('" + altYMD + "','" + altMsg + "') onMouseOut=setAltMsg('" + firstAltYMD + "','" + firstAltMsg + "')><B><FONT size='-2' color='" + iro + "'>" + str + "</FONT></B></TD>";
}
function setAltMsg(altYMD, altMsg){
var editAltMsg = "";
editAltMsg += "<FONT size = '-1'>" + altYMD + "</FONT>";
editAltMsg += "<BR>";
editAltMsg += "<FONT size = '-1'>" + altMsg + "</FONT>";
document.getElementById("altMsg").innerHTML = editAltMsg;
}
//祝日の日にち取得(年、月、第?週の月曜日)
function getSyukujituDate(year, month, syuu){
var syuuCnt = 0;
for(var i=1; i<=31; i++){
var date = (new Date(year, month-1, i)).getDay();
if((new Date(year, month-1, i)).getDay() == 1){
syuuCnt++;
}
if(syuuCnt == syuu){
return i;
}
}
}
//-->
</SCRIPT>

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/30 08:46