Link to home
Start Free TrialLog in
Avatar of perrybond
perrybond

asked on

Document.layers has no properties error

I have the following code that works OK in IE, but I have just tried it in Firefox and I get the following error:
"Document.layers has no properties"
and the line is:
document.layers[i].visibility="hide";

I do not understand Javascript.  Could anyone explain if and how I can get the Javascript to run?


function closeAllMenusExcept(MenuID)
{
var NoOfMenus=10
      for (i=0; i<NoOfMenus; i++ )
      {
        if (navigator.appName=="Netscape"){
        if (i != MenuID){
          document.layers[i].visibility="hide";
        }else{
          document.layers[i].visibility="show";
        }         
      }else{
          var what="menu" + i
        if (i != MenuID){
//              alert(document.all.item(what).innerHTML)
          document.all.item(what).style.visibility="hidden";
        }else{
          document.all.item(what).style.visibility="visible";
        }
        }
      }
}
Avatar of knightEknight
knightEknight
Flag of United States of America image

change this:

   if (navigator.appName=="Netscape")

to this:

   if (document.layers)
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America 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