[日時関係]今年のカレンダーを表示する。
<HTML> <HEAD> <TITLE>カレンダー</TITLE> <SCRIPT language="JavaScript"> <!-- function dsp_calender(month,month_length){ day=1 document.write("<TABLE border=1 bgcolor=blue bordercolorlight=aqua bordercolordark=navy><TR>"); document.write("<TD COLSPAN=7 ALIGN=center bgcolor=#ffffe4><B>"+year+"年 "+month+"</B><TR>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow><font color=red><b>日</TD>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow>月</TD>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow>火</TD>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow>水</TD>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow>木</TD>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow>金</TD>"); document.write("<TD ALIGN=center WIDTH=35 bgcolor=yellow><font color=blue><b>土</TD>"); document.write("</TR><TR>"); for(var i=1;i<start_day;i++){ document.write("<TD bgcolor=white>"); document.write(" "); } for(var i=start_day;i<8;i++){ if (i==7){ document.write("<TD ALIGN=center bgcolor=white><font color=blue><b>"+day+"</TD>"); } else{ document.write("<TD ALIGN=center bgcolor=white>"+day+"</TD>"); } day++ } while(day <= month_length){ document.write("<TR>"); for (var i=1;i<=7 && day<=month_length;i++) { if (i==1){ document.write("<TD ALIGN=center bgcolor=white><font color=red><b>"+day+"</TD>"); } else if (i==7){ document.write("<TD ALIGN=center bgcolor=white><font color=blue><b>"+day+"</TD>"); } else{ document.write("<TD ALIGN=center bgcolor=white>"+day+"</TD>"); } day++; } while(i!=8){ document.write("<TD bgcolor=white> </TD>"); i++; } document.write("</TR>"); start_day=i; } document.write("</TR></TABLE>"); } //--> </SCRIPT> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- today = new Date(); year = today.getYear(); if(year < 2000){ year = year + 1900; } today= new Date("January 1, "+year); start_day = today.getDay() + 1; document.write("<TABLE BORDER=0 CELLPADDING=6><TR><TD valign=top>"); dsp_calender("1月",31); document.write("</TD><TD valign=top>"); if (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)) { dsp_calender("2月", 29); } else { dsp_calender("2月", 28); } document.write("</TD><TD valign=top>"); dsp_calender("3月",31); document.write("</TD></TR><TR><TD valign=top>"); dsp_calender("4月",30); document.write("</TD><TD valign=top>"); dsp_calender("5月",31); document.write("</TD><TD valign=top>"); dsp_calender("6月",30); document.write("</TD></TR><TR><TD valign=top>"); dsp_calender("7月",31); document.write("</TD><TD valign=top>"); dsp_calender("8月",31); document.write("</TD><TD valign=top>"); dsp_calender("9月",30); document.write("</TD></TR><TR><TD valign=top>"); dsp_calender("10月",31); document.write("</TD><TD valign=top>"); dsp_calender("11月",30); document.write("</TD><TD valign=top>"); dsp_calender("12月",31); document.write("</TD></TR></TABLE>"); //--> </SCRIPT> </BODY> </HTML>
|