Tracking a child window through download pages

Can a child window be tracked if the parent page reloads?

I am currently opening a window as follows:

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

and when I want to open the same child window, I do

  childWindow.focus(); 

The obvious problem is that if the parent window is updated, it loses childWindow tracking and cannot focus it. Is there any way to return my link to a child window?

+2
source share
2 answers

Perhaps you could use the name parameter (second) used in window.open () to β€œreload” your popup when the parent window reloads ...?

+2
source

As mentioned above. I did not find a way to get the object of its child windows from the parent window. Probably nothing like the array or windows.childWindows method. After reloading the parent page, you even lost all the bindings created using javascript, for example childWindow = window.open(url,'myChildWindow',opt)

The only possible way I found for FF 3.x is that you know the name of the child window you are looking for. In this case, the window with the same name is opened again, and if it is still open, you should get a lost link. Otherwise, a new window is open. lostWindow = window.open('','myChildWindow','');

Now you need to check if this is your old window or new. For example, some attribute registered in your child window.

if (lostWindow.myProperty == 'yes') you can be sure that this is your lost window.

As I browsed the internet, I found that some people are trying to create a workaround using cookies or in HTML5 with applicationCache .

0
source

Source: https://habr.com/ru/post/954746/


All Articles