最近做网站要用到它,虽然说别人已经实现过很多了,但我还是喜欢自己实现一个。
var mask = function(o) {
var o = $(o);
var maskDiv = document.createElement('div');
maskDiv.id="__maskTag__882366488776";
maskDiv.className="ModalBackground";
Element.setStyle(maskDiv, {position:"absolute", zIndex:1000, left:"0px", top:"0px", Element.getWidth(!ctit.utility.isNull(o)?o:document.body) + "px", height: !ctit.utility.isNull(o)?Element.getHeight(o)+"px":ctit.utility.getViewHeight() + "px"});
if(!ctit.utility.isNull(o)){
var xy = Position.cumulativeOffset(o);
Element.setStyle(maskDiv, {left: xy[0]+"px", top: xy[1]+"px"});
o.appendChild(maskDiv);
}else{
document.body.appendChild(maskDiv);
}
}
var unMask = function() {
var maskDiv=$("__maskTag__882366488776");
if(maskDiv){
document.body.removeChild(maskDiv);
}
}
var o = $(o);
var maskDiv = document.createElement('div');
maskDiv.id="__maskTag__882366488776";
maskDiv.className="ModalBackground";
Element.setStyle(maskDiv, {position:"absolute", zIndex:1000, left:"0px", top:"0px", Element.getWidth(!ctit.utility.isNull(o)?o:document.body) + "px", height: !ctit.utility.isNull(o)?Element.getHeight(o)+"px":ctit.utility.getViewHeight() + "px"});
if(!ctit.utility.isNull(o)){
var xy = Position.cumulativeOffset(o);
Element.setStyle(maskDiv, {left: xy[0]+"px", top: xy[1]+"px"});
o.appendChild(maskDiv);
}else{
document.body.appendChild(maskDiv);
}
}
var unMask = function() {
var maskDiv=$("__maskTag__882366488776");
if(maskDiv){
document.body.removeChild(maskDiv);
}
}