Copy Code code as follows:
Tool method Pop-up mask add by Dning 2012-11-4
var maskshow = (function () {
var mask = null;
var curr = null;
var free = false;
var func = {
Onresize:null,
Onscroll:null
};
return function (EL, fre, Type) {
if (!mask) {
Initmask ();
}
Free =!! Fre
if (el = = null) {
Show (Curr, false);
Show (mask, false);
Showselects (TRUE); For IE6
Curr = null;
if (!free) for (var s in func) {
Window[s] = Func[s];
Func[s] = null;
}
} else {
if (Curr)
Show (Curr, false);
Curr = $ (EL) [0];
Checkvisib (Curr);
RePos ();
Mask.style.zIndex = Maskshow.zindexback | | 15;
Curr.style.zIndex = Maskshow.zindexfore | | 20;
Show (Curr, true);
Show (mask, true);
Showselects (False, EL); For IE6
if (!free) for (var s in func) {
Func[s] = Window[s];
Window[s] = RePos;
}
}
if (Type = = 0) {
Mask.style.width = document.body.clientWidth + ' px ';
Mask.style.height = document.body.clientHeight + ' px ';
if (EL) el.style.position = "fixed";
} else {
Mask.style.width = "0px";
Mask.style.height = "0px";
if (EL) el.style.position = "absolute";
}
};
function showselects (b, Box) {
if (!browser. IE6) return;
var sel = document.getelementsbytagname (' select ');
var vis = b? ' Visible ': ' Hidden ';
for (var i = 0; i < sel.length; i++) {
if (b | |!childof (sel[i], box)) && sel[i].currentstyle.visibility!= vis) sel[i].style.visibility = vis;
}
}
function Childof (A, b) {
While (a && a!= b) a = A.parentnode;
return a = = B;
}
function Initmask () {
/*
Mask=document.createelement (' iframe ');
Mask.src= '://0 ';
*/
Mask = document.createelement (' div ');
Mask.style.cssText = ' background-color:{$c};border:none;position:absolute;visibility:hidden;opacity:{$a};filter: Alpha (opacity={$A}) '. ReplaceWith ({
C:maskshow.bgcolor | | ' #000 ',
A:maskshow.bgalpha | | ' 0.5 ',
A:maskshow.bgalpha? parseint (Maskshow.bgalpha * 100): ' 50 '
});
Document.body.appendChild (mask);
Maskshow.mask = mask;
}
function Checkvisib (EL) {
var sty = El.style;
sty.position = ' absolute ';
Sty.left = ' -10000px ';
Sty.top = ' -10000px ';
sty.visibility = ' visible ';
Sty.display = ' block ';
Sty.zindex = 10;
}
function RePos () {
if (!curr) return;
var PS = $pageSize (' Doc ');
SetRect (Mask, PS);
var rc = Centerpos (PS, Curr.offsetwidth, curr.offsetheight);
if (Rc.left < ps.scrollleft) Rc.left = Ps.scrollleft;
if (Rc.top < ps.scrolltop) Rc.top = Ps.scrolltop;
SetRect (Curr, RC);
}
function Centerpos (PS, CW, CH) {
return {
Left: ((PS.WINWIDTH-CW) >> 1) + Ps.scrollleft + (Maskshow.adjustx | | 0),
Top: ((ps.winheight-ch) >> 1) + Ps.scrolltop + (Maskshow.adjusty | | 0)
};
}
function SetRect (el, rect) {
var sty = El.style;
Sty.left = (Rect.left | | 0) + ' px ';
Sty.top = (Rect.top | | 0) + ' px ';
if (' width ' in rect)
Sty.width = rect.width + ' px ';
if (' Height ' in rect)
Sty.height = rect.height + ' px ';
}
Function Show (EL, b) {
if (!el) return;
el.style.visibility = ' visible ';
if (!b) {
El.style.left =-el.offsetwidth-100 + ' px ';
El.style.top =-el.offsetheight-100 + ' px ';
}
}
})();