18
votes

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?

Can you anyone suggest me the solution?

8

8 Answers

31
votes

try something like this:

function closeAndRefresh(){
  opener.location.reload(); // or opener.location.href = opener.location.href;
  window.close(); // or self.close();
}
4
votes

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();
}
3
votes

I tried code

window.close();
if (window.opener && !window.opener.closed) {
      window.opener.location.reload();
 } 

Its working..

2
votes

window.location.reload(); reloads the parent window.

0
votes
document.opener.document.location.href = document.opener.document.location.href
0
votes

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();
0
votes

The right expression to reload the parent window with a button within an iframe:

parent.location.reload();
0
votes

This function worked for me:

function closeAndRefresh(){
  opener.location.href = opener.location.href;
  window.close(); 
}