Copy code The code is as follows: a Pop up layer and lock screen effect Test< /p>TestTestTestTestTest< /p>Test TestTestTestTest <br>function sAlert(str) <br>{ <br>var msgw,msgh,bordercolor; <br>msgw=400;//Width of prompt window<br>msgh=100;//Height of prompt window <br>titleheight=25 //Title height of prompt window<br>bordercolor="#336699";//Border color of prompt window<br>titlecolor="#99CCFF";//Title color of prompt window<br>var sWidth,sHeight; <br>sWidth=document.body.offsetWidth;//Get the window width<br>sHeight=screen.height;//Get the screen height<br>var bgObj=document.createElement("div");/ /The key is here, the principle: Create a div in the body, and set its width and height to cover the entire form, so that other windows cannot be operated <br>bgObj.setAttribute('id',' bgDiv'); <br>bgObj.style.position="absolute"; <br>bgObj.style.top="0"; <br>bgObj.style.background="#777"; <br>bgObj.style .filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; <br>bgObj.style.opacity="0.6"; <br>bgObj.style.left="0" ; <br>bgObj.style.width=sWidth "px"; <br>bgObj.style.height=sHeight "px"; <br>bgObj.style.zIndex = "10000"; <br>document.body.appendChild (bgObj);//Display this div after setting it<br>var msgObj=document.createElement('div');//Create a message window<br>msgObj.setAttribute("id","msgDiv" ); <br>msgObj.setAttribute("align","center"); <br>msgObj.style.background="white"; <br>msgObj.style.border="1px solid " bordercolor; <br>msgObj .style.position = "absolute"; <br>msgObj.style.left = "50%"; <br>msgObj.style.top = "50%"; <br>msgObj.style.font="12px/1.6 em Verdana, Geneva, Arial, Helvetica, sans-serif"; <br>msgObj.style.marginLeft = "-225px" ; <br>msgObj.style.marginTop = -75 document.documentElement.scrollTop "px"; <br>msgObj.style.width = msgw "px"; <br>msgObj.style.height = msgh "px"; <br>msgObj.style.textAlign = "center"; <br>msgObj.style.lineHeight = "25px" "; <br>msgObj.style.zIndex = "10001"; <br>var title=document.createElement("h4"); //Create a title to be placed in the message layer <br>title.setAttribute(" id","msgTitle"); <br>title.setAttribute("align","right"); <br>title.style.margin="0"; <br>title.style.padding="3px"; <br>title.style.background=bordercolor; <br>title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity =75,finishOpacity=100);"; <br>title.style.opacity="0.75"; <br>title.style.border="1px solid " bordercolor; <br>title.style.height="18px" ; <br>title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; <br>title.style.color="white"; <br>title.style.cursor="pointer" ; <br>title.innerHTML="Close"; <br>title.onclick=function() <br>{ <br>document.body.removeChild(bgObj);//Remove the div layer covering the entire window<br>document.getElementById("msgDiv").removeChild(title);//Remove the title<br>document.body.removeChild(msgObj);//Remove the message layer<br>} <br>document.body.appendChild (msgObj); <br>document.getElementById("msgDiv").appendChild(title); <br>var txt=document.createElement("p"); <br>txt.style.margin="1em 0" <br>txt.setAttribute("id","msgTxt"); <br>txt.innerHTML=str; <br>document.getElementById("msgDiv").appendChild(txt); <br>} <br>< /script> <br></body> <br></html> <br><br> </div>