<pre>
<html>
<head>
<title>遮罩</title>
<script type="text/javascript">
window.onload = function () {
document.getElementById("divshow").style.display = "none";
}
function btnclick() {
document.getElementById("divshow").style.display = "block";
}
</script>
<style type="text/css">
body
{
margin:0px;
padding:0px;
}
divshow
{
position: fixed; /相对于浏览器窗口进行定位/
position:absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
/ 透明度*/
display:none;
z-index:999;
}
bg
{
width:100%;
height:100%;
background:#000;
opacity:0.5;
filter:alpha(opacity=50);
position:absolute;
left:0px;
top:0px;
z-index:1;
}
</style>
</head>
<body>
<input type="button" id="btnShow" onclick="btnclick()" value="显示遮罩" />
<div id="divshow">
<div id="bg" ></div>
</div>
</body>
</html>
</pre>