弹出窗口关闭时刷新父窗口 [英] Refresh parent window when the pop-up window is closed
问题描述
有什么办法可以在关闭弹出窗口时刷新父窗口而不向弹出窗口添加任何javascript代码?
Is there any way I can refresh the parent window when a popup window is closed without adding any javascript code to the popup window?
我有一个父页面。用户可以点击打开弹出窗口打开弹出窗口的php。这个弹出窗口显示了一些flash内容,我无法添加类似
I have a page parent.php on which users can click "open popup" to open a popup window. This popup window shows some flash content and its not possible for me to add something like
window.onunload = function(){
window.opener.location.reload();
};
到弹出窗口页面标记。
还有其他方法可以实现吗?
谢谢
Is there any other method to achieve this? Thanks
推荐答案
要在所有主流浏览器中使用,您需要处理在弹出窗口中卸载
事件处理程序并在主窗口中重新加载。在主窗口中,添加
To make this work in all major browsers, you need to handle the unload
event handler in the pop-up and do the reloading in the main window. In the main window, add
function popUpClosed() {
window.location.reload();
}
在弹出窗口中:
window.onunload = function() {
if (window.opener && !window.opener.closed) {
window.opener.popUpClosed();
}
};
因此,如果您需要在所有浏览器中使用代码,问题的答案通常是否定的,特别是IE。
So the answer to your question is generally no, if you need your code to work in all browsers, in particular IE.
这篇关于弹出窗口关闭时刷新父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!