How to open popup and refresh the parent page on close popup with JavaScript?

Spread the love

To open popup and refresh the parent page on close popup with JavaScript, we use the window.opener property to access the parent window.

For instance, we write

const refreshParent = () => {
  window.opener.location.reload();
};

window.onunload = refreshParent;

to set the window.onunload property to the refreshParent function.

In it, we get the parent window with window.opener.

And we call its location.reload method to reload it.

Leave a Reply

Your email address will not be published. Required fields are marked *