Home arrow HTML arrow Scripting a Common Browser Menu
HTML

Scripting a Common Browser Menu


We have talked about the HTML elements and the CSS for a common browser menu. It is now time to start talking about the script. There are four JavaScript functions that control the horizontal menu and its sub menus. In this part of the series, I give you the name of the functions and their roles. I also start discussing the details of one of the functions. Later on, I give you the complete code.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
March 20, 2009
TABLE OF CONTENTS:
  1. · Scripting a Common Browser Menu
  2. · The Skeleton of the dropDownMenu() Function
  3. · The Second Code Segment
  4. · The dropDownMenu() Function Details

print this article
SEARCH DEVARTICLES

Scripting a Common Browser Menu
(Page 1 of 4 )

The Functions

As I said above, there are four JavaScript functions that control the horizontal menu and its sub menus. These are the functions:

The dropDownMenu() Function

When you click a drop down button, this function is called. It displays a vertical sub menu below the main link preceding the drop down button you clicked. Before it does that, it removes any other drop down menus or sub menus that were on the web page.

The react() Function

The background color of a main menu item and that of a sub menu item is brown. For simplicity, in my design the background color of a main menu item (in the horizontal bar) never changes, even if the mouse pointer is over it. However, the background color of a sub menu item changes when the mouse pointer is over it.

When the mouse pointer goes over any sub menu item on a drop down menu, the background color of the table cell of the menu item changes from brown to firebrick. Only one bar in the firebrick color can be shown at a time on a sub menu. The react() function is responsible for all this.

A sub menu item may have another sub menu, which would come out of its side when the mouse pointer is over the item. If the sub menu is not in the last column on the right of the table, then its sub (sub-sub) menu will come out of its right side. If it is in the last column, then its sub (sub-sub) menu will come out of its left side. The react() function is also responsible for this. Remember that in our design, any sub menu item that can produce a sub menu has the > character on its right.

Again, in menu parlance you do not really talk about sub-sub and sub-sub-sub menus. All sub menus, independent of their level lower down, are referred to simply as sub menus. You can use the phrase sub-sub or sub-sub-sub when you really want to be precise, but you will hardly have to use such phrases.

The react() function also makes sure that only the SPAN elements that are supposed to be displayed are displayed.

The toChoose(ID) Function

When a sub menu is displayed and you click outside the sub menu, the sub menu should disappear. This function sets a variable that is used for that control. We shall see the details later.

The removeSubMenu() Function

This function removes any sub menu (independent of the level) that is displayed. It uses the variable set above for this. We shall see the details for this function and the other three functions later.


blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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