Before using this code, download the jquery library.
Copy codeThe Code is as follows:
Var maskStackCount = 0;
Function mask (method ){
// Here is the window you want to mask. Here I want to mask an iframe window. You can also use var winObj = $ (window)
Var winObj = window. top. $ ("body"). find ("iframe [name = 'dialognormaliframe']");
If (typeof method = "undefined "){
Method = "open ";
}
If (method = "open "){
If (maskStackCount <= 0 ){
Var mask = $ ("<div id = 'window-mask' class = 'window-mask' style = 'display: none'> </div> "). appendTo ("body ");
Mask.css ({
Width: winObj. width () + "px ",
Height: winObj. height () + "px ",
Filter: "alpha (opacity = 60 )"
}). Show ();
WinObj. on ("resize. mask", function (){
Mask.css ({
Width: winObj. width () + "px ",
Height: winObj. height () + "px"
});
});
}
MaskStackCount ++;
}
Else if (method = "close "){
MaskStackCount --;
$ ("# Window-mask"). remove ();
WinObj. off ("resize. mask ");
}
}