简体   繁体   中英

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.

bruh...

function refParent(){
  window.opener.location.reload(); 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM