CSS > 新さっぽろ60+One

JavaScript

8.日付・時刻<57p>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>Calendar</title>
<script language="javascript">
<!--
function calendar(){
date=new Date();
  Month=new Array
(31,28,31,30,31,30,31,31,30,31,30,31)
Days=new Array
("Sun","Mon","Tue","Wed","thr","fri","Sat");
year=date.getYear();
today=date.getDate();
//
if(year<2000){year=year+1900;}
if(((year%4==0)&&(year%100!=0))||(year%400==0)){
Month[1]=29
}
thisMonth=Month[date.getMonth()];
date.setDate(1);
Startday=date.getDay();
//
document.write("<table border=1>");
document.write("<tr><th colspan=7>");
document.write(year,'年',date.getMonth()+1,'月');
document.write("</th></tr>");
//曜日の表示
document.write("<tr>");
for(i=0;i<7;i++){
document.write("<th>",Days[i],"</th>");
}
document.write("</tr>");
//
document.write("<tr>");
col=0;
for(i=0;i<Startday;i++){
document.write("<td></td>");
col++;
}
for(i=1;i<=thisMonth;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("</td>\n<tr>");
col=0
}
}
document.write("</table>");
}
//-->
</script>
</head>
<body>
<script language="javascript">
<!--
calendar()
//-->
</script>
</body>
</html>