'In Javascript, how to refresh parent window from child window without closing the child window?
I tried the following Javascript code where I am trying to reload a parent window from a child window without closing the child window.
<script type="text/javascript">
function refParent () {
if (window != null) {
alert('Not null');
window.opener.reload();
}
else {
alert('null');
}
}
</script>
Then in the HTML code I have the following:
<a href="javascript:void(0);" onclick="refParent();">refresh</a>
I do see that the Javascript function is triggered and the window is not null, but the parent page does not appear to refresh.
Is there a way to refresh the parent page without closing the child window?
PS: I would like to be able to do this with a form submission, where the user sees the results of the form submission in the child window, but the parent window gets refreshed. so the event would be on a form submission rather than a click on a hyperlink.
Solution 1:[1]
function refParent(){
window.opener.location.reload();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | General Grievance |