mjc 发表于 2007-4-27 10:39:15

***时间日期***真正的万年历!

把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件
<html>
<head>

<title></title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#000000" text="#999999" link="#33ff33" vlink="#33ff33" alink="#33ff33" onload="settoday()">
<script language="javascript">
<!-- begin
function settoday() {
var now   = new date();
var day   = now.getdate();
var month = now.getmonth();
var year= now.getyear();
if (year < 2000)   
year = year + 1900;
this.focusday = day;
document.calcontrol.month.selectedindex = month;
document.calcontrol.year.value = year;
displaycalendar(month, year);
}
function isfourdigityear(year) {
if (year.length != 4) {
alert ("sorry, the year must be four-digits in length.");
document.calcontrol.year.select();
document.calcontrol.year.focus();
} else { return true; }
}
function selectdate() {
var year= document.calcontrol.year.value;
if (isfourdigityear(year)) {
var day   = 0;
var month = document.calcontrol.month.selectedindex;
displaycalendar(month, year);
    }
}

function setpreviousyear() {
var year= document.calcontrol.year.value;
if (isfourdigityear(year)) {
var day   = 0;
var month = document.calcontrol.month.selectedindex;
year--;
document.calcontrol.year.value = year;
displaycalendar(month, year);
   }
}
function setpreviousmonth() {
var year= document.calcontrol.year.value;
if (isfourdigityear(year)) {
var day   = 0;
var month = document.calcontrol.month.selectedindex;
if (month == 0) {
month = 11;
if (year > 1000) {
year--;
document.calcontrol.year.value = year;
}
} else { month--; }
document.calcontrol.month.selectedindex = month;
displaycalendar(month, year);
   }
}
function setnextmonth() {
var year= document.calcontrol.year.value;
if (isfourdigityear(year)) {
var day   = 0;
var month = document.calcontrol.month.selectedindex;
if (month == 11) {
month = 0;
year++;

document.calcontrol.year.value = year;
} else { month++; }
document.calcontrol.month.selectedindex = month;
displaycalendar(month, year);
   }
}
function setnextyear() {
var year = document.calcontrol.year.value;
if (isfourdigityear(year)) {
var day = 0;
var month = document.calcontrol.month.selectedindex;
year++;
document.calcontrol.year.value = year;
displaycalendar(month, year);
   }
}
function displaycalendar(month, year) {      
month = parseint(month);
year = parseint(year);
var i = 0;
var days = getdaysinmonth(month+1,year);
var firstofmonth = new date (year, month, 1);
var startingpos = firstofmonth.getday();
days += startingpos;
document.calbuttons.calpage.value=   " su mo tu we th fr sa";
document.calbuttons.calpage.value += "\n --------------------";
for (i = 0; i < startingpos; i++) {
if ( i%7 == 0 ) document.calbuttons.calpage.value += "\n ";
document.calbuttons.calpage.value += "   ";
}
for (i = startingpos; i < days; i++) {
if ( i%7 == 0 ) document.calbuttons.calpage.value += "\n ";
if (i-startingpos+1 < 10)
document.calbuttons.calpage.value += "0";
document.calbuttons.calpage.value += i-startingpos+1;
document.calbuttons.calpage.value += " ";
}
for (i=days; i<42; i++){
if ( i%7 == 0 ) document.calbuttons.calpage.value += "\n ";
document.calbuttons.calpage.value += "   ";
}
document.calcontrol.go.focus();
}
function getdaysinmonth(month,year){
var days;
if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)days=31;
else if (month==4 || month==6 || month==9 || month==11) days=30;
else if (month==2){
if (isleapyear(year)) { days=29; }
else { days=28; }
}
return (days);
}
function isleapyear (year) {
if (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)) {
return (true);
} else { return (false); }
}
// end -->
</script>
<center>
<h2>万年历</h2>
<form name="calcontrol" onsubmit="return false;">
<table cellpadding=0 cellspacing=0 border=0>
<tr><td colspan=7>
<center>
<select name="month" onchange="selectdate()">
<option>一月
<option>二月
<option>三月
<option>四月
<option>五月
<option>六月
<option>七月
<option>八月
<option>九月
<option>十月
<option>十一月
<option>十二月
</select>
<input name="year" type=text size=4 maxlength=4>
<input type="button" name="go" value="创建" onclick="selectdate()">
</center>
</td>
</tr>
</form>
<form name="calbuttons">
<tr><td align="center"><textarea font="courier" name="calpage" wrap=no rows=8 cols=22>
   

      











------- -------------------------------


拥有三人行论坛管理系列软件,一 个人就可以管理一个论坛的更新维护。还能使您的论坛有千人在线的真实火暴效果,让您不 在为论坛因没有人气而 留不住会员而烦恼,使您的论坛早日成为一流的论坛。详情请登陆网站:http://www.cns rx.cn 三人行论坛管理软件, 站长必备的专业好工具。 (您使用的是免费版本,购买收费版本后,将不 带广告。业务QQ:247216 4498 522 7)
页: [1]
查看完整版本: ***时间日期***真正的万年历!