Home arrow HTML arrow Page 2 - 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 / 1
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

TOOLS YOU CAN USE

advertisement
Scripting a Common Browser Menu - The Skeleton of the dropDownMenu() Function
(Page 2 of 4 )

The skeleton of the dropDownMenu() function is as follows:


function dropDownMenu(ID)

{

//Make sure the sub menu of not removed when clicked


for (i=0; i<5; i++)

{

for (j=0; j<5; j++)

{

//remove any sub menu that was displayed.

}

}


for (i=0; i<5; i++)

{

if (document.getElementById(spanID)) //if it exist

{

//display the SPAN elements for the sub menu

}

}


}


Code Segments of the dropDownMenu(ID) Function

There are basically three code segments that comprise the dropDownMenu(ID) function.

The First Code Segment

When any sub menu is displayed, the user has the right to click on the sub menu. Whenever the user clicks on an element (sub menu) on a web page, the BODY element also receives a click indirectly. As we said above, when you click the BODY element, any sub menu displayed should be removed. We do not want the sub menu to be removed when you click on it. This first segment sets a variable, which is used for this purpose (prevention); see the details later.


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 4 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials