Javascript and Menus using styles

Giganews Newsgroups
Subject: Javascript and Menus using styles
Posted by:  Disco (discooctop…@yahoo.com)
Date: Wed, 03 Sep 2003

Hi,

Does anybody know how to make this piece of javascript (below) work in
netscape?  This only works in IE (I have only tried 5.5 and 6).  I would
like to know how to make this work exactly the same way in Netscape.

Thanks very much...

<html>
  <head>
      <script language="JavaScript">
        function doit(pTable){
            if (document.all[pTable].style.display == "none"){
              document.all[pTable].style.display = "block";
            }
            else{
              document.all[pTable].style.display = "none";
            }
        }
      </script>
  </head>

  <body>
      <div class='mainmenu'><a href="#" onclick="doit('Group1');return
false;">Menu One</a></div>
      <div style="display:none;" id="Group1" name="Group1">
        <a href="#">Item 1.1</a><br />
        <a href="#">Item 1.2</a><br />
        <a href="#">Item 1.3</a>
      </div>
      <br />
      <div class='mainmenu'><a href="#" onclick="doit('Group2');return
false;">Menu Two</a></div>
      <div style="display:none;" id="Group2" name="Group2">
        <a href="#">Item 2.1</a><br />
        <a href="#">Item 2.2</a><br />
        <a href="#">Item 2.3</a>
      </div>
  </body>
</html>

Replies