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

HTML/XHTML教程
使用Web标准建站第5天:head区的其他设置
使用Web标准建站第4天:调用样式表
使用Web标准建站第3天:定义语言编码
使用Web标准建站第2天:什么是名字空间
使用Web标准建站第1天:选择什么样的DOCTYPE
使用Web标准建站第12天:校验及常见错误
使用Web标准建站第11天:不用表格的菜单
使用Web标准建站第10天:自适应高度
实现网页渐入特殊效果
实现网页的动态过渡效果
让网页里的提交按钮变得更靓丽
让浏览者记住你的主页
批量消除超链接虚线框
精彩网页九“慎”
解析HTML的增强标记
简单实用的网页表格特效
几个对图形进行动态处理的dhtml代码
基于Web标准的UI组件 — 菜单(1)
关于iframe的透明背景
shtml网页SSI使用详解

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


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