Home arrow HTML arrow Page 4 - More on the React Function for a Common Browser Menu
HTML

More on the React Function for a Common Browser Menu


Welcome to the sixth part of a ten-part series on building a common browser menu. We continue in this part with the in-depth analysis of the react() function. As you may recall, in the last part we noted that the function was composed of five code segments, and began analyzing them. In this part, we shall complete the details of the react() function's fourth code segment and talk about the fifth code segment.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
April 10, 2009
TABLE OF CONTENTS:
  1. · More on the React Function for a Common Browser Menu
  2. · The Fifth Code Segment Details
  3. · Code for the Fifth Code Segment
  4. · More on the Fifth Code Segment

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
More on the React Function for a Common Browser Menu - More on the Fifth Code Segment
(Page 4 of 4 )

In all the iterations, five SPAN IDs are formed. However, the sub menu does not necessarily have five SPAN elements to be displayed. The next statement in the for-loop is an if-statement with its own statements. This if-statement first tests if the SPAN element of the ID we have created exists. If it exists, then the statements in the block are executed; that is, the sub menu next to the drop down menu is formed. Let us now look at what the if-block does.

Only one SPAN element can be shown in a cell in our table at a time. The number part of the IDs of these SPAN elements shown are in corresponding cells in the Number Table. The first statement in the if-block, first of all, creates the ID of any SPAN element that could have been in the cell in which we want to display a new SPAN element. It does this by using any number that could have been in the corresponding cell in the Number Table. In part one of the series I showed you how the number part of the ID of a SPAN element was created. If you have forgotten, go back and review. There can also be more than one SPAN element in a cell, but only one can be displayed at a time.

The next statement checks to see if such a SPAN element was displayed in the cell in which we want to display a new SPAN element. If such a SPAN element is displayed (exists), it is un-displayed; that is, the value of its display property is changed to "none."

Remember that we are now creating the sub menu. The next statement following the if-statement sets the background color of the cell for the iteration number to brown. The statement after that uses the SPAN ID developed before this if-block to display the corresponding SPAN element. The next statement sets the content of the corresponding cell in the Boolean Table to “true.” Finally, the last line in this block sets the content of the corresponding cell in the Number Table to the number part of the SPAN element we have just displayed.

Writing the menu with drop down sub menus has always been a challenge in web site design. There is no standard way of doing it. The difficulty comes from the fact that one browser supports a feature of the specification and another browser does not. The aim of this series is to provide an approach that is common to popular browsers, using features they all supports.

From my experience, if a browser supports a particular design code today, the higher versions of the browser will support the same design tomorrow. So what you learn in this series can be useful even for the next ten years.

In our design so far, there are four functions. We have looked at the details of one. The second function whose details we will examine is the longest function -- in fact, it is longer than all the three functions put together. We shall soon be through with the details of the functions. Have courage; when you complete the series, you will be better off.

I'll see you 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.

blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials