兼容火狐,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; width: 100%; filter: alpha(opacity=70); -moz-opacity: 0.7; opacity: 0.7; } 

 

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

posted @ 2011-10-27 13:07  易独  阅读(315)  评论(0)    收藏  举报
乐巴儿 一个有声音的公众号
长按,识别二维码,加关注