?
Solved

Document.layers has no properties error

Posted on 2004-09-27
2
Medium Priority
?
261 Views
Last Modified: 2012-08-13
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";
        }
        }
      }
}
0
Comment
Question by:perrybond
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 12159459
change this:

   if (navigator.appName=="Netscape")

to this:

   if (document.layers)
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 375 total points
ID: 12159475
function closeAllMenusExcept(MenuID)
{
var NoOfMenus=10
     for (i=0; i<NoOfMenus; i++ )
     {
       if  ( document.layers ){
        if (i != MenuID){
          document.layers[i].visibility="hide";
        }else{
          document.layers[i].visibility="show";
        }        
      }else if ( document.all ){
         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";
        }
       }
     }else {
         var what="menu" + i
        if (i != MenuID){
//            alert(document.all.item(what).innerHTML)
          document.getElementById(what).style.visibility="hidden";
        }else{
          document.getElementById(what).style.visibility="visible";
        }
       }
     }
}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question