宝马娱乐在线城-宝马娱乐在线

来自 互联网络 2019-10-01 21:34 的文章
当前位置: 宝马娱乐在线城 > 互联网络 > 正文

宝马娱乐在线城一个非常精彩的日历程序

我们经常需要的一些Web项目中用到日历,这样的脚本写起来又麻烦,功能又不够强大,现在豆腐给大家
提供一个功能强大的日历程序,这段脚本使用完全的客户端的js脚本制作,运行速度快。
下面大家就来看看,还有什么需要改进的地方,先看看效果再说吧!日历演示
<HTML>
<HEAD>
<TITLE>豆腐日历</TITLE>
<STYLE TYPE="text/css">
.normal{BACKGROUND: #ffffff}
.today {font-weight:bold;BACKGROUND: #6699cc}
.satday{color:green}
.sunday{color:red}
.days {font-weight:bold}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
//中文月份,假如想显示英文月份,修改下面的注释
/*var months = new Array("January?, "February?, "March",
"April", "May", "June", "July", "August", "September",
"October", "November", "December");*/
var months = new Array("一月", "二月", "三月",
"四月", "五月", "六月", "七月", "八月", "九月",
"十月", "十一月", "十二月");
var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31);
//中文周 假如想显示 英文的,修改下面的注释
/*var days = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");*/
var days = new Array("日","一", "二", "三",
"四", "五", "六");
function getDays(month, year) {
//下面的这段代码是判定当前是否是闰年的
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||
(0 == year % 400) ? 29 : 28;
else
return daysInMonth[month];
}

 

function getToday() {
//得到今天的年,月,日
this.now = new Date();
this.year = this.now.getFullYear();
this.month = this.now.getMonth();
this.day = this.now.getDate();
}

<Script LANGUAGE="JavaScript">

today = new getToday();

 var months = new Array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二");

function newCalendar() {

 var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31);

today = new getToday();
var parseYear = parseInt(document.all.year
[document.all.year.selectedIndex].text);
var newCal = new Date(parseYear,
document.all.month.selectedIndex, 1);
var day = -1;

 var days = new Array("日","一", "二", "三","四", "五", "六");

 var classTemp;

 var today=new getToday();

 var year=today.year;

 var month=today.month;

 var newCal;

 function getDays(month, year) {

  if (1 == month) return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28;

  else return daysInMonth[month];

 }

 function getToday() {

  this.now = new Date();

  this.year = this.now.getFullYear();

  this.month = this.now.getMonth();

  this.day = this.now.getDate();

 }

 function Calendar() {

  newCal = new Date(year,month,1);

  today = new getToday();  

  var day = -1;

  var startDay = newCal.getDay();

  var endDay=getDays(newCal.getMonth(), newCal.getFullYear());

  var daily = 0;

  if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth()))

  {

   day = today.day;

  }

  var caltable = document.all.caltable.tBodies.calendar;

  var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear());

  for (var intWeek = 0; intWeek < caltable.rows.length;intWeek++)

   for (var intDay = 0;intDay < caltable.rows[intWeek].cells.length;intDay++)

   {

    var cell = caltable.rows[intWeek].cells[intDay];

    var montemp=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1);        

    if ((intDay == startDay) && (0 == daily)){ daily = 1;}

    var daytemp=daily<10?("0"+daily):(daily);

    var d="<"+newCal.getFullYear()+"-"+montemp+"-"+daytemp+">";

    if(day==daily) cell.className="DayNow";

    else if(intDay==6) cell.className = "DaySat";

    else if (intDay==0) cell.className ="DaySun";

    else cell.className="Day";

    if ((daily > 0) && (daily <= intDaysInMonth))

    {

     cell.innerText = daily;

     daily++;

    } else

    {

     cell.className="CalendarTD";

     cell.innerText = "";

    }

  }

  document.all.year.value=year;

  document.all.month.value=month+1;

 }

 function subMonth()

 {

  if ((month-1)<0)

  {

   month=11;

   year=year-1;

  } else

  {

   month=month-1;

  }

  Calendar();

 }

 function addMonth()

 {

  if((month+1)>11)

  {

   month=0;

   year=year+1;

  } else

  {

本文由宝马娱乐在线城发布于互联网络,转载请注明出处:宝马娱乐在线城一个非常精彩的日历程序

关键词: