This article describes the method of JS+CSS to implement Div pop-up windows and darken the background. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows: <html>
<head>
<title>Div pop-up window implemented by JS+CSS, while the background becomes darker</title>
<script>
function locking(){
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth;
document.all.ly.style.height=document.body.clientHeight;
document.all.Layer2.style.display='block';
}
function Lock_CheckForm(theForm){
document.all.ly.style.display='none';document.all.Layer2.style.display='none';
return false;
}
</script>
<style type="text/css">
<!--
.STYLE1 {font-size: 12px}
a:link {
color: #000;
text-decoration: none;
}
a: visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<p align="center">
<input type="button" value="popup DIV" onClick="locking()" />
</p>
<div id="ly" style="position: absolute; top: 0px; filter: alpha(opacity=60); background-color: #777;
z-index: 2; left: 0px; display: none;">
</div>
<!-- Floating Framework Start-->
<div id="Layer2" align="center" style="position: absolute; z-index: 3; left: expression((document.body.offsetWidth-540)/2); top: expression((document.body.offsetHeight-170)/10);
background-color: #fff; display: none;" >
<table cellpadding="0" cellpacing="0" style="border: 0 solid #e7e3e7;
border-collapse: collapse ;" >
<tr>
<td style="background-color: #73A2d6; color: #ffff; padding-left: 4px; padding-top: 2px;
font-weight: bold; font-size: 12px;" valign="middle">
<div align="right"><a href=JavaScript:; onclick="Lock_CheckForm(this);">[Close]</a> </div></td>
</tr>
<tr>
<td align="center">
<br><br><hr><p align="center"><font color=red>This special effects are collected from the Internet for interest and learning only, and are not for commercial purposes. Source: Wulin.com</font></p>
</td>
</tr>
</table>
</div>
<!-- Floating Framework End-->
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.