Refreshing a Parent Window from a Child Window

A same-origin child window can request a reload of the window that opened it through window.opener.location.reload(), then close itself. This pattern can be useful after the child completes an update that the parent should display.

Opening closing & Passing data from Child window to parent window in JavaScript & refreshing main
On this page

Please read the child window open and child window close tutorials before trying this.

Demo: refresh parent from a child window Top ↑

Complete parent page source Top ↑

<button type="button" id="openChild">Open Window</button>
<script>
document.getElementById("openChild").addEventListener("click", () => {
  window.open("window-child2.html", "Ratting", "width=550,height=170,left=150,top=200,toolbar=0,status=0");
});
</script>

Complete child window source Top ↑

<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Refresh parent from child</title></head>
<body>
<p>This is the child window. Click the button to refresh the parent and close this window.</p>
<button type="button" id="refreshParent">Close this window</button>
<script>
document.getElementById("refreshParent").addEventListener("click", () => {
  if (window.opener && !window.opener.closed) {
    window.opener.location.reload();
  }
  window.close();
});
</script>
</body>
</html>
JQuery Manaing Parent & Child window
Pass data between parent and child windows and refresh part of the parent window after child data changes.

Important notes Top ↑

Direct opener access depends on the opener being present and browser policy allowing the relationship. If all you need is to notify another page of a data change, consider application-level state or messaging rather than forcing a full reload.

Window object Reference Passing data from Child window to parent window




Subscribe to our YouTube Channel here



plus2net.com







muzzamil

01-09-2014

Is there any way to open the left portion of a page in a popup window??
if possible
help me to do it....



We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer