Hey, I came up with a solution. I don't know why I had the error before but I am now doing it a totally different way.
OK, below is the entire HTML document that contains a script you can use to dynamically create window objects and still keep a refernce to each child window in the parent window.
BEGIN HTML DOCUMENT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
In this script, I can create as many new windows as I want
by just creating a link on the page that executes the
openWindow(winURL, winName, winFeatures) function. This in turn
creates a custom object that I defined by calling the popUpWindow
My custom popUpWindow object has 2 properties:
1) unique name of window
2) the actual window object itself.
Then I put that new custom object into an array
object (newWindowsArray) which is Global in scope which allows
me to refer to it anywhere in the code.
Doing this let's me dynamically create new windows but still have
a handle on each window object allowing me to call any of its
methods. For example, I wouldn't be able to close the new window
from the parent window without this object handle.
These scripts are generic which allows me to put it inside a larger
script library file for including in any page that needs
this type of script.
//create a global array object to hold custom poppUpWindow objects
var newWindowsArray = new Array();
//constructor for the custom popUpWindow object
function popUpWindow (winName, windowObject)
this.name = winName;
this.winObject = windowObject;
// function to call in parent window when opening a window
function openWindow(winURL, winName, winFeatures)
// create a new window object using the input parameters from user
var newWindow = window.open(winURL, winName, winFeatures);
// create new popUpWindow object passing in the newly created
// window object's name as the first input parameter and the object
// itself as the second parameter
var win = new popUpWindow(winName, newWindow);
//populate the next index of the window array
newWindowsArray[newWindowsArray.length] = win;
// call focus() for the window object incase the window
// has already been created (you cannot create a window with
// the same name twice)
// function to call in parent document when closing a window
// Pass in the name of the window you want to close as the
// input parameter.
// Loop through the array and try to identify the window in question
for(i=0; i<newWindowsArray.length; i++)
// check each custom popUpWindow object to see if it has
// a matching name as the window the user wants to close
// use object syntax to call the close method of the
// window object. Note, newWindowsArray[i] is the same
// represents the popUpWindow custom object
break; // end loop since you found the window