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

HTML/XHTML教程
按颜色分类:红色系(Red)
按颜色分类:黄色系(Yellow)
网页设计配色精彩十例
按形容词分类:可爱、快乐、有趣
按形容词分类:柔和、明亮、温和
按形容词分类:运动型、轻快
按形容词分类:轻快、华丽、动感
按颜色分类:蓝紫色系(Purple Blue)
按形容词分类:回味、女性化、优雅
按形容词分类:简单、时尚、高雅
按形容词分类:忠厚、稳重、有品位
Xhtml第4天:调用样式表
Xhtml第7天:css入门知识
Xhtml第1天:选择什么样的DOCTYPE
Xhtml第10天:div自适应高度
Xhtml第12天:校验及常见错误
Xhtml第6天:XHTML代码规范
Xhtml第5天:head区的其他设置
Xhtml第8天:CSS布局入门技术
Xhtml第9天:第一个css布局实例

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


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

     else{
      var theCell=theRow.insertCell(j);
      theCell.style.cssText="background-color:#F0F0F0;cursor:default;";
     }
    }
   }

   //****************调整日历位置**************//
   var offsetPos=calendar.getAbsolutePos(calendar.source);//计算对像的位置;
   if((document.body.offsetHeight-(offsetPos.y+calendar.source.offsetHeight-document.body.scrollTop))<calendar.calendarPad.style.pixelHeight){
    var calTop=offsetPos.y-calendar.calendarPad.style.pixelHeight;
   }
   else{
    var calTop=offsetPos.y+calendar.source.offsetHeight;
   }
   if((document.body.offsetWidth-(offsetPos.x+calendar.source.offsetWidth-document.body.scrollLeft))>calendar.calendarPad.style.pixelWidth){
    var calLeft=offsetPos.x;
   }
   else{
    var calLeft=calendar.source.offsetLeft+calendar.source.offsetWidth;
   }
   //alert(offsetPos.x);
   calendar.calendarPad.style.pixelLeft=calLeft;
   calendar.calendarPad.style.pixelTop=calTop;
  }
  /****************** 计算对像的位置 *************************/
  this.getAbsolutePos = function(el) {
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent) {
    var tmp = calendar.getAbsolutePos(el.offsetParent);
    r.x += tmp.x;
    r.y += tmp.y;
   }
   return r;
  };