Didn’t want to leave you folks hanging.
chriskOpener.window3 = window3 doesn’t do it. Another thing I tried is defining a var Window3 when Window1 opens, then set opener.opener.Window3 = Window3 after Window3 is spawned. Then, when Window1 calls for Window2, it passes the Window3 object to the function that opens Window2. I thought it could then check for the existence of Window3. Now worky. Object not defined.
Groman I’m afraid I really don’t see what you are doing there. Seems in your first statements that you are trying to set some sort of loop on an array of objects, but you have no for or while. My windows are not in an array. There will only be 1 window1, 1 window2 and 1 window3 at any time. That’s the whole intent. I also don’t see where you pass the Window3.close() statement.
Let me try to be clearer – And to regress. When the Code in Window1 fires the js function to open Window2, I want it to check for Window3 and close it if it already exists. It does check for an existing Window2 and closes it just fine.
(Code follows, I hope I renamed all the Windows correctly, in RL I am more descriptiive)
Window2 and Window3 are set as global vars in a startup script.
In my main page (Window1) I have this line of code –
<select id="ParcelQueryList" onChange="javascript:QueryTools(ParcelQueryList.value);runat=server>
The QueryTools function is in a javascript file called AXAX.js (maybe the AJAX is screwing me up.) This is the function.
function QueryTools(QueryType){
if (Window2){
Window3 = Window2.document.childNodes(0);
alert(typeof(Window3)); // alerts an object
if(typeof(Window3) == 'object'){
Window3.close(); // fails with a method not found
}
if (!( Window2.closed)) {
Window2.close();
}
}
switch(QueryType) {
case 'PPI':
Window2 = Window.open("Window2.aspx","Window2");
break;
//… other cases are in here.
}
Window2.aspx has a control that calls another function in AJAX.js –
function ParcelQuery(input, QueryType){
// I make an AJAX call to the server here but the var Window3 is set after the call.
var Window3 = window.open("Window3.aspx","Window3");
Seems strange that I can go back to Window1, and close Window2 with no problem. But I can’t find and close Window3 from Window2.