Welcome to WebmasterWorld Guest from 54.161.147.106

Forum Moderators: open

myWindow.close()

not working in FF

   
12:52 pm on Dec 29, 2011 (gmt 0)

5+ Year Member



The following lines work in Opera, IE, GC but not my FF :(


for(var i=0; i < myinputs.length ; i++){
if(myinputs[i].getAttribute("value") == "Open"){
myinputs[i].onclick = function() {
myWindow = window.open('','','width=400,height=200');
myid = document.getElementById("msg");
myid.childNodes[0].nodeValue = "Window is open.";
}
}
if(myinputs[i].getAttribute("value") == "Close") {
myinputs[i].onclick = function() {
if (myWindow){//<<<<is this the offending line?
myWindow.close();
myid = document.getElementById("msg");
myid.childNodes[0].nodeValue = "Window is closed.";
}
}
}
.
.
.


I've tried
if(false == my_window.closed)
in the offending line but FF still refuses to close the window. My research tells me that only a window that was opened by the code may be closed by the code and that is what I am doing, right? The msg "Window is closed." is displayed but the window is still displayed only in FF?
Thanks all.
3:24 pm on Dec 29, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm still on my first cup of coffee and too muddled yet to unwind the code, but two things strike me as potential issues.

First, you use a single variable 'myWindow' to hold the result of window.open which occurs in a for-next loop. If there's a potential for more than one window to be open at a time, then, of course, you can easily run into conflicts.' Second, you don't reset the myWindow variable after you perform window.close(). You may be running into an instance where the variable evaluates to true even though the window is closed. I think the solution probably lies in doing some explicit tracking of the status of the windows you open rather than relying on the variable that holds the Window object. Good luck!
4:26 pm on Dec 29, 2011 (gmt 0)

5+ Year Member



You've touched on something. I shut down FF, restarted, opened one window, then another, clicked close and the recent one closed. I'm on my way to a solution 'by the beans of java I set my mind in motion'. Thanks!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month