首页>互联网>语言脚本>JavaScript>正文

源码学习:一个简单的日历控件(7)

日 期:2006-10-22     来 源:    阅 读:
  
     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;
  };


上一篇:源码学习:一个简单的日历控件(6)   下一篇:网页经典代码(一)
收藏本文到:
digg this! 添加到del.icio.us bbmao网络收藏夹 添加到365key 我顶 添加到bolaa 推荐到奇客发现 添加到新浪vivi 添加到google书签 添加到yahoo+
查看全部JavaScript内容  
 用户名: 新注册) 密码: 匿名发表 评论(0条)
 评论内容:(不能超过250字,不支持HTML或代码,只能发表纯文字,请自觉遵守互联网相关政策法规。)
[an error occurred while processing this directive]
合作伙伴: 电脑综合 8vv8娱乐榜

关于扑虎 | 扑虎新闻 | 联系扑虎 | 广告服务 | 招贤纳士

Copyright @ 2006-2007 poohu.com. All Right Reserved 陕ICP备06010975号