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

HTML/XHTML教程
巧用CSS控制鼠标样式变换
自定多姿多彩的网页链接下划线
CSS快速入门
让字体美起来
显示你个性的鼠标指针
有关表格边框的css语法整理
CSS自定义属性Expression
CSS控制字体效果的思考
巧用CSS滤镜做图案文字
网页常用特效整理:中级篇
网页常用特效整理:初级篇
动态网页巧制作
“渐变窗口”有绝招
网页常用特效整理:高级篇
伴随着Web标准发展建议与好的实例
使用DIV之后,什么时候使用TABLE?
CSS基本布局16例
伴随着Web标准发展
CSSVault推荐的128个CSS布局站点
CSS滤镜:Glow属性

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


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