.opacity{
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity: 0.5;
}
function Mask(){
var fl = document.documentElement.style.overflow;
document.documentElement.style.overflow = 'hidden';
var el = document.createElement('div');
el.id = 'maskDiv';
el.className = 'opacity';
el.style.cssText = 'position:absolute;background-color:#99CCFF;z-index:9999;top:0px;left:0px;'
el.style.width = window.screen.availWidth + 'px';
el.style.height = window.screen.availHeight + 'px';
tip = document.createElement('div');
tip.id = 'tipDiv'
tip.innerHTML = '<div align="center" style="cursor:pointer;border:1px solid #000">单击关闭遮盖层</div>';
tip.style.cssText = 'width:200px;height:200px;background-color:#fff;margin:100px auto';
el.appendChild(tip)
document.body.appendChild(el);
tip.firstChild.onclick = function(){
tip.firstChild.onclick = null;
var el =document.getElementById('maskDiv');
document.body.removeChild(el);
document.documentElement.style.overflow = fl;
}
}
一个简单的遮盖层
最新推荐文章于 2022-01-14 23:13:36 发布