一个简单的遮罩层效果

ContractedBlock.gifExpandedBlockStart.gifCode
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    
<title>一个简单的遮罩层效果</title>
    <script language="javascript">
    
function openwin() {
        
if(document.getElementById("mywinOut"== undefined) {
            
var winOut = document.createElement("div");
            winOut.setAttribute(
"id","mywinOut");
            winOut.style.zIndex
="98";
            winOut.style.left 
= "0";
            winOut.style.top 
= "0";
            winOut.style.width 
= document.body.scrollWidth;
            winOut.style.height 
= document.body.scrollHeight;
            winOut.style.position 
= "absolute";
            winOut.style.background 
= "#cccccc";
            winOut.style.filter
="alpha(opacity=60)";
            winOut.style.opacity
="0.4";
            document.body.appendChild(winOut); 
            
            
var winIn = document.createElement("div");
            winIn.setAttribute(
"id","mywinIn");
            winIn.style.zIndex
="99";
            winIn.style.left 
= document.body.clientWidth/2 - 200;
            winIn.style.top = document.body.scrollTop + 150;            
            winIn.style.width = 400+"px";
            winIn.style.height 
= 400+"px";
            winIn.style.position 
= "absolute";
            winIn.style.background 
= "#ffffff";
            winIn.innerHTML
="<center><br><br><br><input type='button' onclick='closewin()' value='关闭'/></center>";
            document.body.appendChild(winIn); 
        } 
else {
            document.getElementById(
"mywinOut").style.display = "block";
            document.getElementById(
"mywinIn").style.display = "block";
        }
    }
    
    
function closewin() {
        document.getElementById(
"mywinOut").style.display = "none";
        document.getElementById(
"mywinIn").style.display = "none";
    }
    
</script>
</head>

<body>
<center>
<input type="button" onclick="openwin()" value="弹出"/>
<div style="height=1000px"></div>
</center>
</body>
</html>

 

 演示

转载于:https://www.cnblogs.com/arix04/archive/2009/06/17/1505224.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值