Javascript 关闭子窗口时刷新父窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2301278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 23:40:48  来源:igfitidea点击:

refresh parent window when closing child window

javascript

提问by Santhosh

How can I refresh the parent window when clicking the close button of a child window?

单击子窗口的关闭按钮时如何刷新父窗口?

The child window is a pop-up.

子窗口是一个弹出窗口。

采纳答案by rahul

You can access the parent window using

您可以使用访问父窗口

window.opener

and refresh the parent window using

并使用刷新父窗口

window.opener.reload()

See window.opener

window.opener

回答by Chaitra A U

To refresh the parent page on close of child window use the following javascript in the popup page and call that using onunload in the popup page.

要在子窗口关闭时刷新父页面,请在弹出页面中使用以下 javascript 并在弹出页面中使用 onunload 调用它。

function refreshParent() 
{
    window.opener.location.reload(true);
}

<body onunload="javascript:refreshParent()">

回答by Saeros

<body onunload="window.opener.reload();">

If you use this when you close your child window, the parent will be reloaded. window.opener refers to the parent window object.

如果在关闭子窗口时使用它,父窗口将被重新加载。window.opener 指的是父窗口对象。

回答by nmkyuppie

Try this

尝试这个

self.opener.location.reload();