Js pops up the div and displays the Mask Layer
The div is displayed to show the effect of the mask layer. You must have seen it. The following is an example. For more information, see.
The Code is as follows:
// -------------------- Pop-up layer -------------------
// PopDivId: the ID of the pop-up layer div
// DragDivId: ID used to drag a div
// IsShowMask: whether to display the Mask Layer
Function popDivShow (popDivId, dragDivId, isShowMask ){
If (isShowMask ){
CreatMask (popDivId );
}
Var oWins = document. getElementById (popDivId );
Var oWins_title = document. getElementById (dragDivId );
Var bDrag = false;
Var disX = disY = 0;
OWins. style. display = "block ";
OWins_title.onmousedown = function (event ){
Var event = event | window. event;
BDrag = true;
DisX = event. clientX-oWins. offsetLeft;
DisY = event. clientY-oWins. offsetTop;
This. setCapture & this. setCapture ();
Return false;
};
Document. onmousemove = function (event ){
If (! BDrag)
Return;
Var event = event | window. event;
Var iL = event. clientX-disX;
Var iT = event. clientY-disY;
Var maxL = document.doc umentElement. clientWidth-oWins. offsetWidth;
Var maxT = document.doc umentElement. clientHeight-oWins. offsetHeight;
IL = iL <0? 0: iL;
IL = iL> maxL? MaxL: iL;
IT = iT <0? 0: iT;
IT = iT> maxT? MaxT: iT;
OWins. style. marginTop = oWins. style. marginLeft = 0;
OWins. style. left = iL + "px ";
OWins. style. top = iT + "px ";
Return false;
};
Document. onmouseup = window. onblur = oWins_title.onlosecapture = function (){
BDrag = false;
OWins_title.releaseCapture & oWins_title.releaseCapture ();
};
}
// Hide the pop-up layer
Function popDivHidden (popDivId ){
Var oWins = document. getElementById (popDivId );
OWins. style. display = "none ";
Registry.parent.document.body.removechild(registry.parent.doc ument. getElementById ("maskDiv "));
}
// Obtain the zIndex of the pop-up layer
Function getZindex (popDivId ){
Var popDiv = document. getElementById (popDivId );
Var popDivZindex = popDiv. style. zIndex;
Return popDivZindex;
}
// Create a Mask Layer
Function creatMask (popDivId ){
// Parameter w is the width of the pop-up page, parameter h is the height of the pop-up page, and parameter s is the path of the pop-up page
Var maskDiv = callback parent.doc ument. createElement ("div ");
MaskDiv. id = "maskDiv ";
MaskDiv. style. position = "fixed ";
MaskDiv. style. top = "0 ";
MaskDiv. style. left = "0 ";
MaskDiv. style. zIndex = getZindex (popDivId)-1;
MaskDiv. style. backgroundColor = "#333 ";
MaskDiv. style. filter = "alpha (opacity = 70 )";
MaskDiv. style. opacity = "0.7 ";
MaskDiv. style. width = "100% ";
MaskDiv. style. height = (partition partition parent.doc ument. body. scrollHeight + 50) + "px ";
Extends extends parent.doc ument. body. appendChild (maskDiv );
MaskDiv. onmousedown = function (){
Registry.parent.document.body.removechild(registry.parent.doc ument. getElementById ("maskDiv "));
};
}