homepage Welcome to WebmasterWorld Guest from 54.166.123.2
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
myWindow.close()
not working in FF
nyteshade




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

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.

 

rainborick




msg:4402170
 3:24 pm on Dec 29, 2011 (gmt 0)

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!

nyteshade




msg:4402198
 4:26 pm on Dec 29, 2011 (gmt 0)

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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved