プログラム
カレンダの表示は<table>タグを利用します。表になにも書かないと罫線も出ないので、1日までに   (強制の空白)を書き込みます。
<html>
<title>Show Calendar</title>
<script type="text/javascript">
<!--
function showCalender() {
//今日の月のカレンダを表示
//今日の日は赤色で表示
var year, today, startDay, lastday;
var monthdays=new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var days=new Array("Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat");
var date=new Date();//今日の日付を取得
year=date.getFullYear();
today=date.getDate();
//うるう年の検査
if(((year%4==0)&&(year%100!=0))||(year%400==0)) {
monthdays[1]=29;
}
thisMonthdays=monthdays[date.getMonth()];
//1日の曜日を知る
date.setDate(1);
startDay=date.getDay();
date.setDate(thisMonthdays);
lastDay=date.getDay();
//表示開始 年・月表示
document.write("<table border='1'>");
document.write("<tr><th colspan='7' bgcolor='fffafa'>");
document.write(year, '年', date.getMonth()+1, '月');
document.write("</th></tr>");
// 曜日の表示
document.write("<tr>");
for(i=0; i<7; i++) {
if(i==0) {
document.write("<th bgcolor='#ffb6c1'>", days[i], "</th>");
}
else if(i==6) {
document.write("<th bgcolor='#6495ed'>", days[i], "</th>");
}
else {
document.write("<th>", days[i], "</th>");
}
}
document.write("</tr>")
// 日にちの表示
document.write("<tr>");
var col=0;
for(i=0; i<startDay; i++){
document.write("<td> </td>");
col++;
}
for(i=1; i<=thisMonthdays; i++) {
document.write("<td>");
if(i==today) {
document.write("<font color='#ff0000'><b>");
}
document.write(i);
if(i==today) {
document.write("</b></font>");
}
document.write("</td>");
col++;
if(col==7) {
document.write("</tr>\n<tr>");
col=0;
}
}
//残りの日を表示
for(i=lastDay+1;i<7;i++){
document.write("<td> </td>");
}
document.write("</tr>\n");
document.write("</table>");
//document.write("last:"+lastDay);
}
//-->
</script>
<body bgcolor="#fff8dc">
<h3>カレンダーを表示する</h3>
<hr />
<script type="text/javascript">
<!--
showCalender();
//-->
</script>
</body>
</html>