views:

21

answers:

1

Is it possible to track a child window if the parent page is reloaded?

I currently open the window like so:

  var childWindow;
  childWindow= window.open('url...');

and when I want to reopen the same child window I do

 childWindow.focus();

The obvious problem is that if the parent window is refreshed then it loses track of the childWindow and can't focus it. Is there any way to get my reference to the child window back?

+1  A: 

Maybe you could use the name parameter (second one) used in window.open() to "reload" your popup when the parent window reloads... ?

Golmote
Sorry to be a simpleton, but what `name` parameter do you mean? Could you add an example/meta code?
Mr. Flibble
The `open()` method can take three parameters.First one is the URL, second one is the name of the popup, and third one is the options.If you use open() twice with a same popup name, the first call will open a popup to display the first URL, the second call will reload the popup to display the second URL in the same window.So maybe you could use the same popup name every time to keep track of your window ;)
Golmote
Perfect, thanks Golmote.
Mr. Flibble