关闭弹出窗口后刷新父窗口 [英] Refresh parent window after closing a popup window

查看:423
本文介绍了关闭弹出窗口后刷新父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从X.jsp打开一个弹出窗口,并且该弹出窗口由Y.jsp表示.第二个jsp有一个按钮.我想做的是,一旦按下此按钮,就刷新父页面(启动弹出窗口的页面).下面的保存"按钮将在后备bean"copyScriptForVersion"中调用一个方法,单击按钮后我将关闭弹出窗口.关闭弹出窗口后,我还如何刷新父窗口?

I am opening a popup window from X.jsp and the popup is represented by Y.jsp. The second jsp has a button. What I would like to do is to refresh the parent page (the one that launches the popup) once this button is hit. The Save button below will call a method in the backing bean "copyScriptForVersion" and I close the popup on button click. How could I also refresh the parent window after closing the popup?

 <h:commandButton type="submit" value="Save" action="#{copyScriptForVersion.SaveAction}" onclick="window.close()"/>

我尝试添加像onclick ="window.close(); window.opener.reload();"这样的window.opener.reload(),但这没用.

I tried adding window.opener.reload() like this onclick="window.close(); window.opener.reload();", but that didn't work.

我也尝试添加以下内容 body onUnLoad ="window.opener.location.reload(1);">

I also tried adding the following body onUnLoad="window.opener.location.reload(1);">

但是,我收到"window.opener.location为null或不是对象"错误.

But, I got "window.opener.location is null or not an object" error.

推荐答案

首先,您应该在onClick处理程序中将window.close()作为LAST操作执行.否则,它可能永远不会执行.

First of all, you should do window.close() as a LAST action in the onClick handler. Otherwise, it's possible it will never get executed.

第二,如果reload()不起作用,请尝试:

Second, if reload() doesn't work, try:

window.opener.location.href = window.opener.location.href; window.close();

请注意,如果父页面是通过张贴表单生成的,则这可能会导致问题.

Please note that this may cause problems if the parent page was produced as a result of POSTing a form.

这篇关于关闭弹出窗口后刷新父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆