[转]显示ModalExtender一样的弹出效果

显示ModalExtender一样的效果:

http://www.cnblogs.com/xiaoxinzhu/archive/2007/02/16/571027.html
  1. #BOX_overlay {}{
  2.     positionabsolute;
  3.     z-index:100;
  4.     top: 0px;
  5.     left: 0px;
  6.     background-color:#000;
  7.     filter:alpha(opacity=60);
  8.     -moz-opacity: 0.6;
  9.     opacity: 0.6;
  10. }
JavaScript:

  1.     function BOX_show(e){ //显示
  2.     if($get(e)==null){return;}
  3.     BOX_layout(e);
  4.     window.onresize = function(){BOX_layout(e);} //改变窗体重新调整位置
  5.     window.onscroll = function(){BOX_layout(e);} //滚动窗体重新调整位置
  6. }
  7. function BOX_remove(e){ //移除
  8.     window.onscroll = null;
  9.     window.onresize = null;
  10.     $get('BOX_overlay').style.display="none";
  11.     $get(e).style.display="none";
  12. }
  13. function BOX_layout(e){ //调整位置
  14.     var a = $get(e);
  15.     if ($get('BOX_overlay')==null){ //判断是否新建遮掩层
  16.         var overlay = document.createElement("div");
  17.         overlay.setAttribute('id','BOX_overlay');
  18.         overlay.οnclick=function(){BOX_remove(e);};
  19.         a.parentNode.appendChild(overlay);
  20.     }
  21.     //取客户端左上坐标,宽,高
  22.     var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  23.     var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  24.     var clientWidth;
  25.     if (window.innerWidth) {
  26.         clientWidth = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
  27.     } else {
  28.         clientWidth = document.documentElement.clientWidth;
  29.     }
  30.     var clientHeight;
  31.     if (window.innerHeight) {
  32.         clientHeight = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
  33.     } else {
  34.         clientHeight = document.documentElement.clientHeight;
  35.     }
  36.     var bo = $get('BOX_overlay');
  37.     bo.style.left = scrollLeft+'px';
  38.     bo.style.top = scrollTop+'px';
  39.     bo.style.width = clientWidth+'px';
  40.     bo.style.height = clientHeight+'px';
  41.     bo.style.display="";
  42.     //Popup窗口定位
  43.     a.style.position = 'absolute';
  44.     a.style.zIndex=101;
  45.     a.style.display="";
  46.     a.style.left = scrollLeft+((clientWidth-a.offsetWidth)/2)+'px';
  47.     a.style.top = scrollTop+((clientHeight-a.offsetHeight)/2)+'px';
  48. }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值