Link to home
Start Free TrialLog in
Avatar of javagoddess
javagoddess

asked on

One disobedient child window won't close when using FireFox

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
Avatar of discon0
discon0
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
javagoddess,

You might also want to delete the duplicate question here,
https://www.experts-exchange.com/questions/22916063/One-disobedient-child-window-won't-close-when-using-FireFox.html before anyone answers so that you can keep your points and all the answers in one place.  
SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
Community Support Moderator