Or grand grand grand (to the infinity) parent window.

I had a hard time googling the net about this issue, so I created this solution.

The problem of the persons having this problem is shown in this situation:

1.) the parent window open the child window
2.) the child window open the grand child window
3.) the child window closes

What created the problem here is the step 3, so if you have a code opener.location.reload(); on the grand child window, it cannot reference the parent window since it’s parent is the child window, simply because it is the one who opens it.

I wouldn’t give the complete codes here. All i gonna do is to give the logic to solve this situation.

So, if the problem is the step 3, it closing itself, then the solution is simply not closing the child window. And after you done processing on the grand child window, make a code that will execute like opener.location.href=”childwindow.php?reloadclose=yes”; then close it self.

As you have noticed, I placed a variable reloadclose on the url. If the child window sees this variable it will also pass a code to the parent window like opener.location.href=”childwindow.php?reloadclose=yes”; or opener.location.reload(true);, then close it self.

This chain of course can be done to as many window as you would like. I’m not sure if what I’m doing here is the best way to do this, but what I know is this code / technique is not ugly. It follows basic conditional coding and the most important is… it works!

Hope you got the logic, but if you have any questions, please feel to comment below, I would be very much willing to answer them back.

Related posts:

  1. Javascript – Creating an Array From Multiple Textboxes