Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: How to get a list of all open windows

Suppose you open a handful of windows with:

  window.open(url1,'win1');
  window.open(url2,'win2');
  window.open(url3,'win3');

(each window has a unique name)

And then you refresh the page.

The 3 popup windows are still open. Is there a way to list the names of all of the open windows and close them?

This is not a duplicate question.

In this question the browser is being refreshed, so you cannot simply use a global array to keep track of child windows.

This is not a duplicate question.

like image 810
Brian McGinity Avatar asked Jul 07 '14 01:07

Brian McGinity


Video Answer


1 Answers

So the questions is closed, I'll post an answer based on the comments and research.

Firstly, to all who commented, thank you for helping.

Answer: There is not a built-in object which tracks opened windows and persists from page load to page load.

As Felix Kling pointed out, using localStorage is a possible work-around.

like image 194
Brian McGinity Avatar answered Oct 05 '22 23:10

Brian McGinity