How to get the references of all already opened child windows

I want to get the references of all already opened child windows. is there any way? I am not using child = window.open(....) just using window.open(....) and opening multiple child windows.


If you don't want to change your current code, you can simply override window.open() function:

var openedWindows = [];
window._open = window.open; // saving original function
window.open = function(url,name,params){
    openedWindows.push(window._open(url,name,params));
    // you can store names also...
}

Run this code before calling window.open(). All the references to the opened windows will be stored in openedWindows array. You can access them anywhere you want


I don't believe you can, unless you know the windows' names, which I'm guessing you don't. (If you know their names, you can use window.open("", "name") to get a reference to them.)

The better option is, of course, to remember the reference returned from window.open in the first place — but you know that. :-)


Ok, I used the answers to this question in Oracle CRM onDemand to disable a select in a popup window executing the script from the parent window, and it worked! (I have no control over the generation of popup windows, they are opened by the application framework)

Let's see how I did it:

Context: In a detail page the user can add some info by clicking in a magnifying glass icon >>> a new window opens containing a search form, but a select is disturbing the administrator: If the user change its default value he/she will gain access to forbidden records!! Oh my God!

First Approach: Disable that select now!!

Attempt: I found the image's onclick attrib with my browser's dev tools (F12). There was a openAssocPopup method, and then i knew the name of the child window: 'OccamPopup1' :)

Okay! So let's do some magic (executed at the parent window):

window.open("","OccamPopup1").document.getElementById("frmSearch.AQ").setAttribute("disabled", true);

I think this may help, as this question helped to me too. You were right. Now i'm trying to wrap the child's document object within the parent's jQuery object so i can gain access to the entire child's DOM... but this is another story...