ModalDialog下控制父窗口
父窗口打开子窗口代码:
<script language="javascript" type="text/javascript">
function cancelOrder(orderId) {
var url = "CancelOrder.aspx?orderId=" + orderId;
var s = window.showModalDialog(url, window, "dialogWidth: 450px; dialogHeight: 300px; help: no; scroll: no; status: no");
if (s == 1) {
alert('操作成功!');
self.location.reload();
}
return s;
}
</script>
子窗口操作
<script language="javascript" type="text/javascript">
window.returnValue=1;
window.close();
</script>
其它相关:
aspx页面在showmodeldialog情况下为什么一提交就重新打开一个页面?
showmodaldialog打开的页面中在<head></head>之间加入一行:<base target="_self">
结果传递数组参数
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章");
var result = window.showModalDialog("h2.html",mxh1);
var s='';
for(i=0;i<result.length;i++)
s +=result[i];
alert("返回值是:"+s);
</script>
h2.html内容如下:
<script>
var a = window.dialogArguments;
alert('0:'+a[0]+',1:'+a[1]+',2:'+a[2]);
var dd = new Array('aaa','bbb','ccc');
window.returnValue =dd;
</script>