Javascript 使用javascript从子窗口刷新父窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4667714/
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
Refresh parent window from child window using javascript
提问by Abhishek B.
I am opening new pop-up page in new window. Now When I am pressing a html input button from child window, I want to close this child window then I want to refresh the parent window. How I can do using javascript?
我正在新窗口中打开新的弹出页面。现在,当我从子窗口按下 html 输入按钮时,我想关闭这个子窗口,然后我想刷新父窗口。我如何使用 javascript?
Can you anyone suggest me the solution?
你能告诉我解决方案吗?
回答by oezi
try something like this:
尝试这样的事情:
function closeAndRefresh(){
opener.location.reload(); // or opener.location.href = opener.location.href;
window.close(); // or self.close();
}
回答by Sevenearths
you could try this in you child window:
你可以在你的子窗口中试试这个:
function refreshParent() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close()
}
window.close();
}
回答by Abhishek B.
I tried code
我试过代码
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
Its working..
它的工作..
回答by ahimmelstoss
window.location.reload();
reloads the parent window.
window.location.reload();
重新加载父窗口。
回答by Nimble Fungus
Below function worked for me.
以下功能对我有用。
function closeAndRefresh(){
opener.location.href = opener.location.href;
window.close();
}
回答by Eugene Abao
Just try this simple code:
试试这个简单的代码:
// parentPage.php is the parent page you want to redirect and refresh.
window.opener.location.href="parentPage.php";
self.close();
回答by hungryMind
document.opener.document.location.href = document.opener.document.location.href