Chinaunix首页 | 论坛 | 博客
  • 博客访问: 485997
  • 博文数量: 33
  • 博客积分: 4168
  • 博客等级: 上校
  • 技术积分: 675
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-26 20:21
文章分类

全部博文(33)

文章存档

2013年(8)

2012年(2)

2011年(7)

2010年(1)

2009年(4)

2008年(11)

分类: JavaScript

2013-08-01 11:04:05

    在使用http://www.cnblogs.com/junjie94wan/archive/2011/08/24/2152637.html 的第2种日历当中,发现日历在extpb.net的应用中存在Y坐标定位不准确的现象,故做下如下修改:

原来的2代码:

点击(此处)折叠或打开

  1. ...

  2. while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
  3.     dads.top = (ttyp=="image")? ttop+thei : ttop+thei+6;

  4. ...
修改为:

点击(此处)折叠或打开

  1. while (tt = tt.offsetParent) {
  2.     ttop += tt.offsetTop - tt.scrollTop;
  3.     tleft += tt.offsetLeft;
  4. }
  5. var ifrdiv_top = (ttyp == "image") ? ttop + thei : ttop + thei + 6;
  6. //日历控件的高度
  7. var ifrdiv_hei = parseInt(document.all.endDateLayer.height);
  8. //浏览器的高度
  9. var br_hei = getViewportHeight();
  10. if (br_hei - ifrdiv_top < ifrdiv_hei) ifrdiv_top -= (ifrdiv_hei + thei + 8); //移到TT控件的上面显示
  11. dads.top = ifrdiv_top;
其中增加了一个获取浏览器高度的函数 getViewportHeight() ,定义如下:

点击(此处)折叠或打开

  1. function getViewportHeight()
  2. {
  3.     if (document.compatMode == "BackCompat")
  4.     return document.body.clientHeight;
  5.    else return document.documentElement.clientHeight;
  6. }
同时将如下对控件大小的修改直接写到iframe的定义里:

 //--------------------------------------
 // add by cd.NET 2008-05-28
 if (dads != null) {
        dads.width = '162px';
        dads.height = '211px';
    }
    //--------------------------------------

document.writeln('');
====>
document.writeln('');

效果:
          

            a) 下部页面空间够时在下面显示日历                                       b) 下部页面空间不够时在上面显示日历







阅读(1302) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~