Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> a pop-up layer and lock screen effect </title>
<body>
<div>
<div>
<p> Test </p><p> Test </p><p> Test </p><p> Test </p><p> test </p><p > Testing </p><p> Testing </p>
<p> Test </p><p> Test </p><p> Test </p><p> Test </p><p> test </p><p > Testing </p><p> Testing </p>
<input type= "button" value= "click here" onclick= "Salert (' test pop-up layer and lock screen effect ');"/>
</div>
</div>
<script language= "JavaScript" >
function Salert (str)
{
var Msgw,msgh,bordercolor;
msgw=400;//the width of the prompt window
msgh=100;//the height of the prompt window
TITLEHEIGHT=25//Hint window header height
Bordercolor= "#336699";//Hint window border color
Titlecolor= "#99CCFF";//Hint window title color
var swidth,sheight;
swidth=document.body.offsetwidth;//Get window width
sheight=screen.height;//Get screen height
var bgobj=document.createelement ("div");//Key here, principle: Create a div in the body, and set its width and height to cover the entire form, so that no other window can be manipulated
Bgobj.setattribute (' id ', ' bgdiv ');
bgobj.style.position= "Absolute";
bgobj.style.top= "0";
Bgobj.style.background= "#777";
Bgobj.style.filter= "Progid:DXImageTransform.Microsoft.Alpha" (style=3,opacity=25,finishopacity=75);
bgobj.style.opacity= "0.6";
bgobj.style.left= "0";
Bgobj.style.width=swidth + "px";
Bgobj.style.height=sheight + "px";
BgObj.style.zIndex = "10000";
Document.body.appendChild (bgobj)//After setting this div to display it
var msgobj=document.createelement (' div ');//Create a message window
Msgobj.setattribute ("id", "msgdiv");
Msgobj.setattribute ("Align", "center");
msgobj.style.background= "White";
Msgobj.style.border= "1px solid" + bordercolor;
MsgObj.style.position = "absolute";
MsgObj.style.left = "50%";
MsgObj.style.top = "50%";
Msgobj.style.font= "12px/1.6em Verdana, Geneva, Arial, Helvetica, Sans-serif";
MsgObj.style.marginLeft = " -225px";
MsgObj.style.marginTop = -75+document.documentelement.scrolltop+ "px";
MsgObj.style.width = msgw+ "px";
MsgObj.style.height = msgh+ "px";
msgObj.style.textAlign = "center";
MsgObj.style.lineHeight = "25px";
MsgObj.style.zIndex = "10001";
var title=document.createelement ("H4"); Create a title for placement in the message layer
Title.setattribute ("id", "msgtitle");
Title.setattribute ("Align", "right");
title.style.margin= "0";
Title.style.padding= "3px";
Title.style.background=bordercolor;
Title.style.filter= "Progid:DXImageTransform.Microsoft.Alpha (startx=20, starty=20, finishx=100, finishy=100,style= 1,OPACITY=75,FINISHOPACITY=100); ";
Title.style.opacity= "0.75";
Title.style.border= "1px solid" + bordercolor;
Title.style.height= "18px";
Title.style.font= "12px Verdana, Geneva, Arial, Helvetica, Sans-serif";
title.style.color= "White";
title.style.cursor= "Pointer";
Title.innerhtml= "Close";
Title.onclick=function ()
{
Document.body.removeChild (bgobj)//Remove the div layer covering the entire window
document.getElementById ("Msgdiv"). RemoveChild (title);//Remove Caption
Document.body.removeChild (msgobj);//Remove message layer
}
Document.body.appendChild (Msgobj);
document.getElementById ("Msgdiv"). AppendChild (title);
var txt=document.createelement ("P");
Txt.style.margin= "1em 0"
Txt.setattribute ("id", "msgtxt");
TXT.INNERHTML=STR;
document.getElementById ("Msgdiv"). appendchild (TXT);
}
</script>
</body>