趁热打铁,又做了个遮罩层

var masking = {
    // opacity: float number between 0 and 1
    open : function(domIdStr, opacity){
        var mask = document.getElementById(domIdStr);
        mask.style.visibility = \'visiable\';
        mask.style.position = \'absolute\';
        mask.style.zIndex = \'90\';
        mask.style.left = \'0\';
        mask.style.top = \'0\';
        mask.style.width = \'100%\';
        mask.style.height = \'100%\';
        mask.style.backgroundColor = "#000";
        if(/msie/i.test(navigator.userAgent)){
            mask.style.filter = \'alpha(opacity=\' + (opacity * 100) + \')\';
        }else{
            mask.style.opacity = opacity;
        }
    },
    close : function(domIdStr){
        var mask = document.getElementById(domIdStr);
        mask.style.visibility = \'hidden\';
    }
}

用法:在HTML页面</body>之前添加<div id=”mask”></div>,调用open方法即可。

版权声明:本文为realwall原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/realwall/archive/2011/10/21/2220720.html