The aim of this series is to come up with code that can be used by all browsers without having code segments addressing the peculiarities of different browsers. I accomplished this in part in a previous series, but I needed to use extra code segments, and there were still some problems. This nine-part series addresses those problems while accommodating more browsers.
A Menu for All Browsers - The Main Menu (Page 5 of 5 )
The main menu here does not have drop down buttons. I did not make any provision for that; I did not allocate any cell for that. There are five cells. Each cell has a link. Each cell and its content (link) is a main menu item. Clicking a link takes you to a page. Nothing happens when you click inside a cell but outside the link.
Each cell has an ID. The values are from D0 to D4. Each cell has an onmouseover event. When the mouse pointer goes over a cell a function, dropDownMenu(ID) is called. This function uses the ID of the cell to drop down the corresponding menu. In other words, this function uses the ID to change the value of the display property of the corresponding table from "none" to "block."
Note: the width of each cell of your main menu should be the same as the width of the corresponding drop down table. However, you can make the widths of these cells be different from one another. Give all of your tables and all of their cells the width they should have. If you do not do this, some browsers may not display your tables correctly.
In the example in this series, the main menu table has been given the following attribute:
border="1"
This means that all of the cells of this table have borders that are one pixel thick. The nature (color) of the border depends on the browser. From my experience, browsers generally choose appropriate colors. So I have not given any color to these borders.
We have done a lot for this part of the series. In the next part of the series I will explain the details of the layout. For the main table of the sub menus above, I have not mentioned the attributes of the tag. The attributes are important. I will explain that as we go along in the next part of the series.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.