This is a follow up to my last question Open a window if the window does not already exist Essentially, I am now keeping a list of all the window references that have been o
Setup an array, and increment it with window references when you open them...
var wins = new Array();
function openWindow(url) {
wins.push(window.open(url));
}
Then when you wish to check the status of the windows, you can loop through them like this, and remove the windows that are not opened...
function updateWindowArray() {
for(var i = 0, l = wins.length; i < l; i++) {
if(wins[i] == null || wins[i].closed)
arrayRemove(wins, i, i + 1);
}
}
function arrayRemove(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
}
Best regards...