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

HTML/XHTML教程
回答XML与HTML的区别
举一反三 浅谈在网页上显示日期的两种方法
打开“保护之门”—破解网页限制功能
“快马加鞭”—网站浏览提速七种武器
用FAQGenie迅速制作“常见问答”网页
流程图软件Visio作“高难度”网页
动态HTML教程(二)
动态HTML教程(一)
动态HTML教程(三)
Html源文件中image标签的析取
什么是Dynamic HTML
关于CSS中的类-CLASS
什么是CSS?它的能做些什么?
如何将 CSS 加诸于网页
CSS产生的特殊效果
CSS的字体、字型控制
使用不同的CSS写法-CSS进阶
HTML的基本元素
Html的几个小技巧
WEB界面设计五种特征

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 76 ::
收藏到网摘: 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);
     }