模态弹出窗口刷新父窗体

问:

我在做一套系统的时候碰到这样一个问题。

弹出的模态窗口不能刷新父窗体。例如我新增数据是在模态窗口而添加成功了关闭后父窗体只能手动刷新。这样就严重影响了一些效果。

我尝试过一些方法但是始终不对。请各位高手进来一下。

用OPEN打开的不管是在关闭窗体时自动刷新都没有任何问题。见下例

父窗体代码

<%@ page contentType="text/html; charset=GBK" %>

<html>

<head>

<title></title>

</head>

<body>

<a href="javascript:void(0)" οnclick="window.open('2.html','','')">open</a>

</body>

</html>

子窗体代码

<%@ page contentType="text/html; charset=GBK" %>

<html>

<head>

<title></title>

</head>

<body onUnload="opener.location.reload()">

<!-

用按纽直接刷新父窗体

<a href="javascript:opener.location.reload()">刷新</a>

->

</body>

</html>



换做模态后的程序。

父窗体代码

<%@ page contentType="text/html; charset=GBK" %><HEAD>

<body onUnload="opener.location.reload()">

<script language="JavaScript">

function showabout()

{

var returnValue=showModalDialog('2.html','','dialogWidth:520px;dialogHeight:510px;help:no;center:yes;resizable:no;status:no;scroll:no');

}

void(0);

</script>

<a href="javascript:void(0)" onClick="showabout()">open</a>

子窗体代码

<%@ page contentType="text/html; charset=GBK" %>

<html>

<head>

<title></title>

</head>

<body onUnload="opener.location.reload()">

<a href="javascript:opener.location.reload()">刷新</a>

</body>

</html>



请各位参考一下上面的代码,我感觉错误好象是出在

opener.location.reload()

谢谢

______________________________________________________________________________________________

答1:

模态窗口不能在子窗口中直接刷新父窗口

父窗体代码

<%@ page contentType="text/html; charset=GBK" %><HEAD>

<body onUnload="opener.location.reload()">

<script language="JavaScript">

function showabout()

{

var returnValue=showModalDialog('2.html','','dialogWidth:520px;dialogHeight:510px;help:no;center:yes;resizable:no;status:no;scroll:no');

location.reload()//模态窗口传值下来后就可以刷新了.

}

void(0);

</script>

<a href="javascript:void(0)" onClick="showabout()">open</a>

子窗体代码

<%@ page contentType="text/html; charset=GBK" %>

<html>

<head>

<title></title>

</head>

<body onUnload="opener.location.reload()">

<a href="javascript:opener.location.reload()">刷新</a>//???在子窗口中不能刷新父窗口,只有window.close下去后才可刷新.

</body>

</html>

______________________________________________________________________________________________

答2:

模态对话框是不能用opener引用父窗口的,而是需要父窗口主动传递指针变量的

这个window.showModalDialog有第二个参数,就是做这个用的,你需要把window穿过去,就是这样

var returnValue=showModalDialog('2.html',window,'dialogWidth:520px;dialogHeight:510px;help:no;center:yes;resizable:no;status:no;scroll:no');

这样在对话框中就可以引用父窗口对象,怎么引用呢,通过window.dialogArgument就可以应用父窗口了。

______________________________________________________________________________________________

答3:

谢谢。我终于搞定了。

上面的dialogArgument差个S

我调了半天。发现在body里面应该加上location

也就是<body onUnload="window.dialogArguments.location.reload()">
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值