兼容火狐,IE 的遮罩层

脚本:

/*添加全局禁用div*/
function DisabledAll(value) {
    var my = document.createElement("div");
    document.body.appendChild(my);
    my.className = "layerGray";
    var ContentHeight = document.body.scrollHeight; //其它浏览器默认值
    if (navigator.userAgent.indexOf("Chrome") != -1)
        ContentHeight = document.body.clientHeight;
    if (navigator.userAgent.indexOf("Firefox") != -1)
        ContentHeight = document.body.offsetHeight+300;
    my.style.height = ContentHeight + 300 + 'px';
    my.innerHTML = value;
}

 样式:
/*整个页面变灰*/
.layerGray { background-color: Gray; color: Red; position: absolute; z-index: 100; top: 0px; left: 0px; 100%; filter: alpha(opacity=70); -moz-opacity: 0.7; opacity: 0.7; } 

测试:     <input type="button" value="test" onclick="DisabledAll('此页面已经禁用');" />

联盟快卖 商人,生意人,待创业人士在此可以共赢互利 期待你的加入 群号:140809277
原文地址:https://www.cnblogs.com/yexinw/p/2226395.html