troubleshooting Question

One disobedient child window won't close when using FireFox

Avatar of javagoddess
javagoddess asked on
JavaScriptWeb BrowsersWeb Applications
4 Comments2 Solutions856 ViewsLast Modified:
I am trying to solve an orphaned child window problem that is happening in Firefox. I dont know javascript very well, and I didnt write this, but the person who did is very knowledgeable. Neither of us can figure out whats wrong here.

There is an initial window, window1. A webpage is presented in window1 after signon to the webapp. From window1, a link is clicked which opens a new child window, window2,  with javascript:openWindowNoBar(&). On window2, there are two buttons, ContactUs and Help. Each of these opens a child window, ContactUs=window3, and Help=window4.  For ContactUs there is a call to javascript openContact; for Help there is a call to javascript openHelp. The signOff link on window1 calls the closeAll javascript function.

The desired behavior is, if the user goes back to window1 and clicks sign off, all child windows should close, and window1 should revert to signon page.  All this happens, except for window3, which remains open when using Firefox. Everything works correctly using IE.

I inspected the cookie theChildWindow each step of the way, and the expected values were there. When signoff occurred, the cookie remained, and its value was empty. Even though the contact window remained, its cookie value was gone.  Any suggestions?

Here are the functions that are called in the jsp.

function openContact(url)
{
      Set_Cookie("theChildWindow", "Contact", "/");
      var  contactWin = "";
      contactWin = window.open(url,'Contact','menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=620,height=450');
      contactWin.focus();
      return false;
}

function openHelp(url)
{
      var  helpWin = "";
      helpWin = window.open(url,'Help','menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=620,height=450');
      helpWin.focus();
      Set_Cookie("theChildWindow", "Help", "/");            
      return false;
}

function Get_Cookie(name)
{
      var start = document.cookie.indexOf(name+"=");
      var len = start+name.length+1;
      if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
      if (start == -1) return null;
      var end = document.cookie.indexOf(";",len);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,path)
{
      var domain = "ourCompany.com";
      var cookieValue = Get_Cookie(name);
      if (cookieValue != null) {
            if (cookieValue.indexOf(value) == -1) {
                  cookieValue += "," + value;
            }
            else {
                  return true;
            }      
      }
      else {
            cookieValue = value;
      }
      document.cookie = name + "=" +escape(cookieValue) + ( (path) ? ";path=" + path : "") + ( (domain) ? ";domain=" + domain : "");
}

function closeAll(url)
{            
      var appIds = Get_Cookie("theChildWindow");
      if ((appIds == '') || (appIds == null)) {
            thisWin = window.open("", 'statusSessionWin', 'toolbar=no,status=no,menubar=no,resizable=yes,width=1,height=1,top=2000,left=2000,z-lock=yes');
            thisWin.close();
            return true;
      }
     
      else {      
            var allApps = new Array();
            allApps = appIds.split(',');      
            for (counter=0; counter < allApps.length; counter++)
            {
                  if (allApps[counter] == '') { continue; }
                  thisWin = window.open("", allApps[counter], 'toolbar=no,status=no,menubar=no,resizable=yes,width=1,height=1,top=2000,left=2000,z-lock=yes');
                  thisWin.close();                        
            }      
      }
     
      Kill_Cookie("theChildWindow", '', "/");
      var appIds = Get_Cookie("theChildWindow");
      thisWin = window.open("", 'statusSessionWin', 'toolbar=no,status=no,menubar=no,resizable=yes,width=1,height=1,top=2000,left=2000,z-lock=yes');
      thisWin.close();      
}

function Kill_Cookie(name,value,path)
{
      var domain = "ourCompany.com";
      var killCookie = Get_Cookie(name);
      killCookie = value;
      document.cookie = name + "=" +escape(killCookie) + ( (path) ? ";path=" + path : "") + ( (domain) ? ";domain=" + domain : "");
      return true;
}

Any help to solve this question will be greatly appreciated. :)
ASKER CERTIFIED SOLUTION
discon0

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros