<html>
<head>
<title>日历</title>
</head>
<body>
<div align="center">
<script type="text/javascript">
var m = new Date();
function Leap(k){
if (k % 400 == 0 || (k % 4 == 0 && k % 100 != 0)) {
return true;
} else {
return false;
}
}
function showDate(year,month,day) {
var i=1;
var j1=1;
var theday=1;
var max;
var tempday;
/* var k=2012;
var j=8; */
var s = ""+ year +"-" + month +"-"+1;
var b = new Date(Date.parse(s.replace(/\-/g,"/")));
/*alert(b.getDay());
alert(s);*/
document.write("<input type='button' value='返回现在时间' οnclick='showCurrentDate();' >");
document.write ("<b><h1 align='center'><font color='blue'>" + ( year ) + "年" + ( month ) +"月"+ "</font></h1></b>");
document.write ("<hr>");
document.write ("<hr>");
document.write ("<table border='3' width='400' height='200' align='center'>");
document.write ("<tr>");
document.write ("<td height='30' width='50'><font color='red'>星期日</font></td>");
document.write ("<td height='30' width='50'>星期一</td>");
document.write ("<td height='30' width='50'>星期二</td>");
document.write ("<td height='30' width='50'>星期三</td>");
document.write ("<td height='30' width='50'>星期四</td>");
document.write ("<td height='30' width='50'>星期五</td>");
document.write ("<td height='30' width='50'><font color='red'>星期六</font></td>");
document.write ("</tr>");
tempday=b.getDay();
if(month ==1||month==3||month==5||month==7||month==8||month==10||month==12) {
max=31; }
if(month ==4||month==6||month==9||month==11){
max=30; }
if (month ==2) {
max=Leap(year)?28:29;}
for(i=0;i<6;i++) {
document.write ("<tr>");
for(j1=0;j1<=6;j1++) {
document.write ("<td height='30' width='50'>");
if(j1>=(tempday)) {
tempday=0;
if(theday<=max) {
document.write ("<a title=" + year + "-" + month + "-" +theday+">");
if(j1==0||j1==6)
document.write ("<font color='red'>" + (theday==day?"[" + theday+"]":theday) + "</font></a>");
else
document.write ((theday==day?"[" + theday+"]":theday) + "</a>");
theday++;
}
}
document.write ("</td>");
}
document.write ("</tr>");
}
document.write ("</table>");
}
function clicks(){
document.write("<form>");
document.write("<input type='text' name='setYear'>年");
document.write("<input type ='text' name='setMonth'>月");
document.write("<input type='button' value='确定' target='_blank' οnclick='showDate(setYear.value,setMonth.value);' >");
document.write("</form>");}
</script>
<script language="javascript">
function showCurrentDate() {
var today = new Date();
//在日历中显示当前日期
showDate(today.getFullYear(),today.getMonth()+1,today.getDate())
}
clicks();
showCurrentDate();
</script>
</div>
</div>
<body>
</html>
<head>
<title>日历</title>
</head>
<body>
<div align="center">
<script type="text/javascript">
var m = new Date();
function Leap(k){
if (k % 400 == 0 || (k % 4 == 0 && k % 100 != 0)) {
return true;
} else {
return false;
}
}
function showDate(year,month,day) {
var i=1;
var j1=1;
var theday=1;
var max;
var tempday;
/* var k=2012;
var j=8; */
var s = ""+ year +"-" + month +"-"+1;
var b = new Date(Date.parse(s.replace(/\-/g,"/")));
/*alert(b.getDay());
alert(s);*/
document.write("<input type='button' value='返回现在时间' οnclick='showCurrentDate();' >");
document.write ("<b><h1 align='center'><font color='blue'>" + ( year ) + "年" + ( month ) +"月"+ "</font></h1></b>");
document.write ("<hr>");
document.write ("<hr>");
document.write ("<table border='3' width='400' height='200' align='center'>");
document.write ("<tr>");
document.write ("<td height='30' width='50'><font color='red'>星期日</font></td>");
document.write ("<td height='30' width='50'>星期一</td>");
document.write ("<td height='30' width='50'>星期二</td>");
document.write ("<td height='30' width='50'>星期三</td>");
document.write ("<td height='30' width='50'>星期四</td>");
document.write ("<td height='30' width='50'>星期五</td>");
document.write ("<td height='30' width='50'><font color='red'>星期六</font></td>");
document.write ("</tr>");
tempday=b.getDay();
if(month ==1||month==3||month==5||month==7||month==8||month==10||month==12) {
max=31; }
if(month ==4||month==6||month==9||month==11){
max=30; }
if (month ==2) {
max=Leap(year)?28:29;}
for(i=0;i<6;i++) {
document.write ("<tr>");
for(j1=0;j1<=6;j1++) {
document.write ("<td height='30' width='50'>");
if(j1>=(tempday)) {
tempday=0;
if(theday<=max) {
document.write ("<a title=" + year + "-" + month + "-" +theday+">");
if(j1==0||j1==6)
document.write ("<font color='red'>" + (theday==day?"[" + theday+"]":theday) + "</font></a>");
else
document.write ((theday==day?"[" + theday+"]":theday) + "</a>");
theday++;
}
}
document.write ("</td>");
}
document.write ("</tr>");
}
document.write ("</table>");
}
function clicks(){
document.write("<form>");
document.write("<input type='text' name='setYear'>年");
document.write("<input type ='text' name='setMonth'>月");
document.write("<input type='button' value='确定' target='_blank' οnclick='showDate(setYear.value,setMonth.value);' >");
document.write("</form>");}
</script>
<script language="javascript">
function showCurrentDate() {
var today = new Date();
//在日历中显示当前日期
showDate(today.getFullYear(),today.getMonth()+1,today.getDate())
}
clicks();
showCurrentDate();
</script>
</div>
</div>
<body>
</html>