浏览 5393 次
锁定老帖子 主题:JS遮盖层解决方案
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-08-22
最后修改:2008-11-25
页面中的HTML <div id="bg" class="bg"> </div>
CSS代码 .bg { display:none; background-color: #666; filter:alpha(opacity=50);/*IE*/ opacity:0.5;/*FF*/ z-index:10; position:absolute; }
JS代码 function getPageSizeWithScroll(){ if (window.innerHeight && window.scrollMaxY) {// Firefox yWithScroll = window.innerHeight + window.scrollMaxY; xWithScroll = window.innerWidth + window.scrollMaxX; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac yWithScroll = document.body.scrollHeight; xWithScroll = document.body.scrollWidth; } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari yWithScroll = document.body.offsetHeight; xWithScroll = document.body.offsetWidth; } return [xWithScroll, yWithScroll]; } function SuperMan() { var de = document.documentElement; return { show_bg: function(){ var size = getPageSizeWithScroll(); $("#bg").css({left:0, top:0, width:'100%', height:size[1]}).show(); }, hide_bg: function(){ $("#bg").hide(); } } }
JS代码 function SuperMan() { var _select_cache; return { show_bg: function(hide_select){ var size = getPageSizeWithScroll(); $("#bg").css({left:0, top:0, width:'100%', height:size[1]}).show(); if(hide_select) { _select_cache = $('select:visible'); _select_cache.css('visibility', 'hidden'); } }, hide_bg: function(){ $("#bg").hide(); if( _select_cache ) { _select_cache.css('visibility', 'visible'); _select_cache = false; } } } } window.superman = SuperMan();
调用示例: superman.show_bg(); superman.hide_bg();
over 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |