|
页面中的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) {// FirefoxyWithScroll = window.innerHeight + window.scrollMaxY;xWithScroll = window.innerWidth + window.scrollMaxX;} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer MacyWithScroll = document.body.scrollHeight;xWithScroll = document.body.scrollWidth;} else { // works in Explorer 6 Strict, Mozilla (not FF) and SafariyWithScroll = 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 |
|