当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 源码学习:一个简单的日历控件(6)

HTML/XHTML教程
dl、dt、dd列表标签实例
XHTML语言默认的CSS样式
干净的XHTML语法
XHTML常用的结构标签
HTML 5草案并没有成为正式标准
innerHTML应用
网页制作有用的代码
IE6实现min-width
innerHTML的认识
自定义html标记替换html5新增元素
基链接标签base的使用介绍
HTML5中的新元素介绍
HTML语言大全
HTML教程:收集的常用的HTML标签(4)
网页设计关于表单输入框的技巧代码
XHTML标签的自关闭的写法应该注意的问题
初学者接触HTML了解一些HTML标记(3)
网页制作中注意应用HTML标签的问题
XHTML网页教程
初学者接触HTML了解一些HTML标记(2)

HTML/XHTML教程 中的 源码学习:一个简单的日历控件(6)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 28 ::
收藏到网摘: n/a

   if(defaultDate==undefined || defaultDate==""){
    var theDate=new Array();
    calendar.head.innerText = calendar.today[0]+"-"+calendar.today+"-"+calendar.today;
    theDate[0]=calendar.today[0]; theDate=calendar.today; theDate=calendar.today;
   }
   else{
    var reg=/^\d{4}-\d{1,2}-\d{2}$/
    if(!defaultDate.match(reg)){
     alert("默认日期的格式不正确\n\n默认日期可接受格式为:'yyyy-mm-dd'");
     return;
    }
    var theDate=defaultDate.split("-");
    calendar.head.innerText = defaultDate;
   }
   calendar.currentDate[0]=theDate[0];
   calendar.currentDate=theDate;
   calendar.currentDate=theDate;
   theFirstDay=calendar.getFirstDay(theDate[0],theDate);
   theMonthLen=theFirstDay+calendar.getMonthLen(theDate[0],theDate);
   //calendar.setEventKey();

   calendar.calendarPad.style.display="";
   var theRows = Math.ceil((theMonthLen)/7);
   //清除旧的日历;
   while (calendar.body.rows.length > 0) {
    calendar.body.deleteRow(0)
   }
   //建立新的日历;
   var n=0;day=0;
   for(i=0;i<theRows;i++){
    theRow=calendar.body.insertRow(i);
    for(j=0;j<7;j++){
     n++;
     if(n>theFirstDay && n<=theMonthLen){
      day=n-theFirstDay;
      calendar.insertBodyCell(theRow,j,day);
     }