http://www.csdn.net/develop/Read_Article.asp?Id=15245
解决方案 »
- 麻烦请教一个功能的js实现
- 怎样让一个区域处在浏览器的中间?
- 请教一个关于对象的问题
- JS如何判断鼠标两次点击的时间间隔??
- 一个算法问题---在javascript中给定一个日期怎样得到他的星期
- vbscript:如何获取后台数组的元素值啊
- 怎样给jqgrid中的特定行显示特定颜色?怎样在单元格中增加超链接?
- 关于百度富文本编辑器
- 请教:哪里有介绍CSS滤镜的资料啊?
- mongoose怎么populate别的集合的子文档?
- 请教一个用javascript控制框架的问题
- 大家帮忙看看这个网址左边蓝色的那个菜单怎么做的啊,http://www.math.pku.edu.cn/index_cn_2004.asp
<head>
<title></title><script language="JavaScript" type="text/JavaScript">
<!--
var OutputString;function julianDay( Y, M, D ){
var y,m,d;
// Guard against arguments that are really passed as strings:
y=parseInt(Y);
m=parseInt(M);
d=parseInt(D);
var jy,ja,jm;
// Don't permit year zero: it does not exist in the Julian calendar:
if( y==0 ){
alert("There was no year zero in the Julian calendar.");
return "invalid";
}
// Don't permit the missing 10 days in October of 1582:
if( y==1582 && m==10 && d>4 && d<15 ){
alert("October 5th to 14th were skipped in October of 1582\nwhen Pope Gregory XIII implemented the calendar reforms\nof the commission headed by the Jesuit mathematician and astronomer\nChristoph Clavius.");
return "invalid";
}
// Negative years represent years before the Common Era (BCE).
// Correct for the fact that there was no year zero:
if(y<0) y++; if(m>2){
jy=y;
jm=m+1;
}else{
jy=y-1;
jm=m+13;
}
var julian = Math.floor( Math.floor(365.25*jy) + Math.floor(30.6001*jm) + d + 1720995 );
// Check for the switch to the Gregorian calendar:
var gregorianStart = 15 + 31*( 10 + 12*1582 );
if( d + 31*(m + 12*y) >= gregorianStart ){
ja = Math.floor(0.01*jy);
julian += 2 - ja + Math.floor(0.25*ja);
}
// return the Julian day number:
return julian;
}function julianGregorianDate( julian ){
var j1, j2, j3, j4, j5;
// This is of course the Julian day number
// for October 15, 1582:
var gregorianStart = 2299161;
if( julian >= gregorianStart ){
var tmp = Math.floor( ( (julian - 1867216) - 0.25 ) / 36524.25 );
j1 = julian + 1 + tmp - Math.floor(0.25*tmp);
}else{
j1 = julian;
}
j2 = j1 + 1524;
j3 = Math.floor( 6680.0 + ( (j2 - 2439870) - 122.1 )/365.25 );
j4 = Math.floor(j3*365.25);
j5 = Math.floor( (j2 - j4)/30.6001 );
var d = Math.floor(j2 - j4 - Math.floor(j5*30.6001));
var m = Math.floor(j5 - 1);
if( m > 12 ) m -= 12;
var y = Math.floor(j3 - 4715);
if( m > 2 ) y--;
if( y <= 0 ) y--;
return formatISODate(y,m,d);
}function dayOfWeek( julian ){
return (julian+1)%7;
}function padWithZeros(number,length) {
var str = "" + number;
while( str.length < length ) str = '0' + str;
return str;
}
// Date delimiter:
var delimiter="-";
if(year<0){
year= -year; year = "-" + padWithZeros(year,4);
}else{
year = padWithZeros(year,4);
}
return year + delimiter + padWithZeros(month,2) + delimiter + padWithZeros(day,2);
}function callCalendarPlan()
{
var today = new Date();
objectId = 'theDate';
year=today.getFullYear();
month=today.getMonth()+1;
day=today.getDate();
generateCalendar( year, month, day, objectId );
}function callCalendar( dateString ){
//var dateString=document.getElementById( objectId ).value;
// Normalize possibly variant delimiters to the ISO preferred delimiter:
objectId = 'theDate';
var re = new RegExp( '[/\.\ ]', 'gi' );
dateString=dateString.replace( re, "-" );
// Split the date string:
dateComponents=dateString.split("-");
var year,month,day;
year=dateComponents[0];
month=dateComponents[1];
day=dateComponents[2];
generateCalendar( year, month, day, objectId );
}//
// setDate()
//
function setDate(day){
// Format the date string:
year =document.getElementById("currentYear").value;
month=document.getElementById("currentMonth").value;
isoDateString=formatISODate(year,month,day);
// Get the destination object id:
idString = document.getElementById("destinationId").value;
// Store the value:
//window.opener.document.getElementById( idString ).value=isoDateString;
//window.close();
}//
// previousYear()
//
function previousYear(){
year =parseInt(document.getElementById("currentYear").value);
month=parseInt(document.getElementById("currentMonth").value);
day =parseInt(document.getElementById("currentDay").value);
destination = document.getElementById("destinationId").value;
year -= 1;
// Remember that there was no year zero:
if( year==0 ) year = -1;
//
// NOTE BENE: The generateCalendar() function *MUST* be called
// from the "window.opener" window. Otherwise, if you just call
// "generateCalendar()" from *this* window, then the "opener"
// property becomes the calendar popup window itself in the new
// incarnation of the calendar window -- instead of being
// the form window -- and then you would be stuck with no
// way to access the form elements in the main form window!
//
//window.opener.generateCalendar(year,month,day,destination);
}//
// previousMonth()
//
function previousMonth(){
year =parseInt(document.getElementById("currentYear").value);
month=parseInt(document.getElementById("currentMonth").value);
day =parseInt(document.getElementById("currentDay").value);
destination = document.getElementById("destinationId").value;
month -= 1;
if(month<1){
month = 12;
year -= 1;
if( year==0 ) year = -1;
}
//window.opener.generateCalendar(year,month,day,destination);
}
// nextMonth()
//
function nextMonth(){
year =parseInt(document.getElementById("currentYear").value);
month=parseInt(document.getElementById("currentMonth").value);
day =parseInt(document.getElementById("currentDay").value);
destination = document.getElementById("destinationId").value;
month += 1;
if(month>12){
month = 1;
year += 1;
if( year==0 ) year = 1;
}
//window.opener.generateCalendar(year,month,day,destination);
}//
// nextYear()
//
function nextYear(){
year =parseInt(document.getElementById("currentYear").value);
month=parseInt(document.getElementById("currentMonth").value);
day =parseInt(document.getElementById("currentDay").value);
destination = document.getElementById("destinationId").value;
year += 1;
// Remember that there was no year zero:
if( year==0 ) year = 1;
//window.opener.generateCalendar(year,month,day,destination);
}function generateCalendar( Y, M, D, targetId ){
// Names of the Months:
//var Month = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var Month = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
// Days of the Week:
//var Day = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
var Day = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
// Digits (if you want to use something other than Arabic-Indic digits):
// var Digits = new Array("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
var daysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var daysInAWeek=7;
// Guard against arguments that are really passed as strings:
// Get year:
var today = new Date();
if( Y=="" || isNaN(Y) ){
thisYear=today.getFullYear();
}else{
thisYear=parseInt(Y);
}
// Get month:
if( M=="" || isNaN(M) ){
thisMonth=today.getMonth()+1;
}else{
thisMonth=parseInt(M);
if(thisMonth<1) thisMonth=1;
if(thisMonth>12) thisMonth=12;
}
// Get day:
if( D=="" || isNaN(D) ){
thisDay=today.getDate();
}else{
thisDay=parseInt(D);
if(thisDay<0) thisDay=1;
if(thisDay>31) thisDay=31;
}
// Calculate the number of days in February:
if ((thisYear % 4) == 0){
daysInMonth[ 1 ] = 29;
if((thisYear % 100) == 0 && (thisYear % 400) != 0){
daysInMonth[ 1 ] = 28;
}
}
// Document header:
OutputString = " ";
// Start the calendar table with day headings:
OutputString += "<table border='0' width='100%' cellpadding='4' cellspacing='1'>\n <tr>\n";
OutputString += " <td bgcolor='#f7f3f7' align='right'><div class=\"cssleftstretcharrow\" onclick=\"previousYear()\">上年<!-- left arrow --></div></td>\n";
OutputString += " <td bgcolor='#f7f3f7'><div class=\"cssleftarrow\" onclick=\"previousMonth()\">上月<!-- left arrow --></div></td>\n"; // Print the year heading: If year<0, negate and print "BCE"; if 0<year<1000, print "CE":
OutputString += " <td bgcolor='#f7f3f7' colspan=\"3\" align='center'><font color='#6600FF'><B>";
if( thisYear < 0 ) yearString = -thisYear + " BCE";
else if( thisYear < 1000 ) yearString = thisYear + " CE";
else yearString = thisYear;
OutputString += yearString + "年\n";
// Print the month heading:
OutputString += Month[ thisMonth-1 ] + "</B></font></td>"; OutputString += " <td bgcolor='#f7f3f7' align='right'><div class=\"cssrightarrow\" onclick=\"nextMonth()\">下月<!-- right arrow --></div></td>\n";
OutputString += " <td bgcolor='#f7f3f7'><nobr><div class=\"cssrightstretcharrow\" onclick=\"nextYear()\">下年<!-- right arrow --></div></nobr></td>\n";
OutputString += "</tr>\n<tr width='2' bgcolor='#000066'>\n<td colspan='7'>\n</td>\n</tr>\n<tr width='20'>\n<td bgcolor='#f7f3f7' colspan='7'>\n</td>\n</tr>\n<tr>\n";
for(i=0;i<daysInAWeek;i++){
OutputString += " <td bgcolor='#f7f3f7' align='center'>" + Day[i] + "</td>\n";
}
OutputString += " </tr>\n <tr>\n";