iframe里弹出的层显示在整个网页上

17 篇文章 0 订阅

1.在子页面中做好弹窗布局以及css,备用

.showPopup{
	position: fixed;top: 0;background-color:rgba(0,0,0,0.3) ;width: 100%;height: 100%;
}
.showPopup>.Popupcotent{
	position: fixed; top: 47%;width:500px;left:20%;height: auto; background-color: #FFFFFF;
}
.showPopup>.Popupcotent>.PopupcotentTitle{
	background-color: #000000;color: #FFFFFF;height:60px;line-height: 60px;
}
.showPopup>.Popupcotent>.PopupcotentTitle>.titlename{
	padding-left:10px;font-size:20px;font-family:SimSun;font-weight:400;
}
.showPopup>.Popupcotent>.PopupcotentTitle>.titleclear{
	text-align: right;margin-top: 10px;width: 48%
}
.showPopup>.Popupcotent>.PopupcotentTitle>.titleclear>img{
	    vertical-align: inherit;
}
.showPopup>.Popupcotent>input{
	margin-top:20px;margin-left:15px; width: 94%;height: 50px;
}
.showPopup>.Popupcotent>button{
	width: 94%;margin-left: 15px;margin-top: 20px;height: 46px;margin-bottom: 20px;
}

 

2.在子页面中将整个要显示的弹窗编辑为字符串,赋值给一个变量,如:showdiv

3.使用window.parent.document.body.appendChild("showdiv")动态添加到首页。

var showdiv=document.createElement('div');				 
showdiv.setAttribute("class","showPopup");
showdiv.setAttribute('id','showPopuPassWord');
var tt="<div class='Popupcotent'>"+
		"<div class='flex PopupcotentTitle'>"+
		"<div class='width50 titlename'>交易密码	</div>"+
		"<div class='titleclear'>"+
		"<img src='img/cha.svg' onclick='HideShowPas()'/>"+						
		"</div></div>"+					
		"<input  value='' name='jiaoyiPassword' placeholder='交易密码8-20位数字+字母+特殊字符'/>"+
		"<button onclick='setPassWord()'>确定</button></div>";	
showdiv.innerHTML=tt;
window.parent.document.body.appendChild(showdiv);

 

4.关闭弹窗要使用window.parent.document.body.removeChild("showdiv")移除div,不能使用display做隐藏。

function HideShowPas(){
	var showdiv=document.getElementById('showPopuPassWord');
	window.parent.document.body.removeChild(showdiv);	
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值