Forum Moderators: open
When loading a page I include this js-file so I can use it's functions later on. In this file i have a global variable, whisch is an array.
Later on I call a debugging function in this file 2 times, each time creating a new popup-window with some debugging-info. The references to the windows is stored in the global array (using array.unshift()).
However later on when accessing the array only the last window-object is contained in the array, and the array.length is 1, not 2 as expected. It seems that when calling my debug-function a second time the reference to the first window is "forgotten". Why is this? Shouldn't the global array be able to hold a reference across function-calls?
regards tores
regards tores
var debugwin = new Array();//*********************//
// Debugging functions //
//*********************//
function opendebugwindow(debugmsg){
if(navigator.appName == "Netscape"){
var name = debugmsg;
}else if(navigator.appName == "Microsoft Internet Explorer"){
var name = alphabetize(debugmsg);
}else{
alert("Could not show debuginfo because the browser, "+navigator.appName+", is unknown");
return;
}
debugwin.unshift(window.open('', name, 'height=600, width=400, scrollbars=yes, resizable=yes'));
/* Always prints 1! */
alert(debugwin.length);
debugwin[0].document.write(debugmsg);
debugwin[0].document.close();
if(navigator.appName == "Netscape")
debugwin[0].addEventListener("keydown", ff_eventhandler, true);
else
debugwin[0].document.onkeypress = ie_eventhandler;
}