[thelist] DHTML Syntax Problem

javascript@LaTech.edu javascript at LaTech.edu
Thu, 2 Dec 1999 13:51:49 -0500


Does anyone know why when the following is executed in Netscape Communicator 4.6
I get the error:

JavaScript Error:
file:/D|/Temp/test.htm, line 15:
document.layers[idMainMenu] has no properties.

Any help would be appreciated.  I thought javascript access to DIV tags was
through the document.layers object (in Netscape).

Gregory

Snippet of Code:

<html>
<head>
<title></title>
<script language="JavaScript">

<!--

   function displaySubMenu( idMainMenu )
   {

      var submenu;

      submenu = document.layers["sub"+idMainMenu];

      submenu.left = document.layers[idMainMenu].pageX;
      submenu.top  = document.layers[idMainMenu].pageY + 19;
      submenu.visibility = "show";

   }

//-->

</script>
</head>

<body>

<TABLE>
   <TR><TD>
      <DIV id='submenu' style='visibility:hidden'>
         <table>
            <tr><td><A href='index1.html'>SubMenu 1</A></td></tr>
            <tr><td><A href='index2.html'>SubMenu 2</A></td></tr>
         </table>
      </DIV>
      <DIV id='menu'><A href='index.html'
onmouseover="displaySubMenu('menu');">Main Menu</A></DIV>
   </TD></TR>
</TABLE>

</body>
</html>