1、主窗口代码:(弹出层"divEdit", 遮照层"mask", 弹出层内放入一ifrme)
<head runat="server">
<title>配送方式</title>
<mce:style type="text/css"><!--
.header
{
background: #036;
height: 10%;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
padding: 3 5 0 5;
color: #fff;
}
#divEdit
{
position: absolute;
left: expression((body.clientWidth-290)/2);
top: expression((body.clientHeight-180)/2);
width: 290px;
height: 190px;
filter: dropshadow(color=#666666,offx=3,offy=3,positive=2);
filter: ALPHA(opacity=70);
z-index: 2;
visibility: hidden;
}
#mask
{
position: absolute;
top: 0;
left: 0;
width: expression(body.clientWidth);
height: expression(body.clientHeight);
background: #666;
filter: ALPHA(opacity=60);
z-index: 1;
visibility: hidden;
}
</style>
<mce:script type="text/javascript"><!--
var payType = {}
payType.Add = function(){
var ID = document.form1.hID.value;
var frameid = document.getElementById("editframe");
frameid.src = "CarriageType_Edit.aspx?Type=Add";
document.getElementById("divEdit").style.position = "absolute";
document.getElementById("divEdit").style.top = screen.availWidth/2 - 450;
document.getElementById("divEdit").style.left = screen.availHeight/2 - 50;
document.getElementById("divEdit").style.display = "block";
document.getElementById("mask").style.visibility='visible'; //遮照层
document.getElementById("divEdit").style.visibility='visible'; //弹出层
}
payType.Edit = function(){
var ID = document.form1.hID.value;
if(ID==""){
alert("请选择要编辑的行!");
return false;
}else{
var frameid = document.getElementById("editframe");
frameid.src = "CarriageType_Edit.aspx?Type=Edit&ID=" + ID;
document.getElementById("divEdit").style.position = "absolute";
document.getElementById("divEdit").style.top = screen.availWidth/2 - 450;
document.getElementById("divEdit").style.left = screen.availHeight/2 - 50;
document.getElementById("divEdit").style.display = "block";
document.getElementById("mask").style.visibility='visible'; //遮照层
document.getElementById("divEdit").style.visibility='visible'; //弹出层
}
}
payType.Delete = function(){
var ID = document.form1.hID.value;
if(ID==""){
alert("请选择要删除的行!");
return false;
}else{
return confirm("确定删除该支付方式吗?");
}
}
//关闭弹出层、拖动弹出层
var Obj='';
document.οnmοuseup=MUp;
document.οnmοusemοve=MMove;
function MDown(Object){
Obj=Object.id;
document.all(Obj).setCapture();
pX=event.x-document.all(Obj).style.pixelLeft;
pY=event.y-document.all(Obj).style.pixelTop;
}
function MMove(){
if(Obj!=''){
document.all(Obj).style.left=event.x-pX;
document.all(Obj).style.top=event.y-pY;
}
}
function MUp(){
if(Obj!=''){
document.all(Obj).releaseCapture();
Obj='';
}
}
// --></mce:script>
</head>
<body>
<form id="form1" runat="server">
<!-- 主窗体内容 -->
<p>
<input id="btnAdd" type="button" οnclick="payType.Add()" value="新增" style="width: 90px;" />
<input id="btnEdit" type="button" οnclick="payType.Edit()" value="编辑" style="width: 90px;" />
<asp:Button ID="btnDelete" runat="server" Text="删除" OnClientClick="return payType.Delete()"
Width="90" OnClick="btnDelete_Click" />
</p>
<!-- 遮照层 -->
<div id="mask">
</div>
<div id="divEdit" style="display: none; z-index: 2000;" mce_style="display: none; z-index: 2000;">
<div class="header" οnmοusedοwn="MDown(divEdit)">
<div style="display: inline; cursor: move; width: 220px; position: absolute">
配送方式
</div>
<span οnclick="divEdit.style.visibility='hidden'; mask.style.visibility='hidden'"
style="float: right; display: inline; cursor: hand" mce_style="float: right; display: inline; cursor: hand" title="关闭窗口 ">× </span>
</div>
<iframe id="editframe" frameborder="0" scrolling="no" width="290px" height="110px"></iframe>
</div>
</form>
</body>
</html>
2、子窗体Iframe代码:(当点击确定按钮后,直接操作主窗体内的层 + 刷新主窗体)
<mce:script type="text/javascript"><!--
function Check()
{
// iframe 内访问主窗体的元素
parent.document.all("divEdit").style.visibility = "hidden";
parent.document.all("mask").style.visibility = "hidden";
parent.location.reload(); //刷新父窗体
//top.location.reload()
}
// --></mce:script>