Click here to Skip to main content
15,434,297 members
Articles / Web Development / CSS
Posted 8 Sep 2005


12 bookmarked

Dropdown menu utility - Using Javascript, CSS and DOM

Rate me:
Please Sign up or sign in to vote.
1.70/5 (5 votes)
8 Sep 2005CPOL1 min read
An Javascript utility that help programmer to create drop down menu easily

Sample screenshot


Recently our team needs to have drop down menu on our intranet site. Most of the people in the team are web designers and I am the only developer in the team, so I need to find a way to let them implement the drop down menu easily. Well, I can do that using dreamweaver, but the code that it generates is not that easily to modify (and the code is lengthy!). Hence, I decided to create an drop down menu utility to the team.


This utility is written in Javascript. And it is suitable for 3 different type of mouse event - onMouseOver, onMouseClick, and page dependent. Here are the examples to implement the menu. You can see how easy it is.

Sample 1 - display sub menu when onMouseOver
<a href="link_0" class="rightArrowGreen marginLeft10 block" 
<div id="Layer_a" class="dropdownMenu">

In sample #1, just use onMouseOver to call MM_showHideLayers function.

Sample 2 - display sub menu when onMouseClick

<a href="#" class="rightArrowGreen marginLeft10 block"
<div id="Layer_a" class="dropdownMenu">
The utility have a function called isLayerDisplay(layername) used to return boolean value whether the layer is displaying or not.

Sample 3 subpage 1 - display sub menu based on specific page
<a href="sample3_subpage1.asp" class="rightArrowGreen marginLeft10 block"
<div id="Layer_a" class="dropdownMenu">
<script type="text/javascript">
Sample #3 is page dependent, so you just need to specify the page that you want to display in the javascript ( MM_showHideLayers('Layer_a','','rightArrowGreen','rightArrowDownGreen','','sample3_subpage1.asp','<%=request.ServerVariables("SCRIPT_NAME")%>'); </script>)
As you can see, the drop down menu is not that difficult to implement. I welcome to all of you to improve my script to be more flexible. Thanks for reading my article.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Web Developer
Canada Canada
I am working as a IT developer in S+A. This is my favourite job that I would like to do in the rest of my life.

Nothing is perfect, but I will do my best!

Comments and Discussions

Questiondivya Pin
divya.hyd@gmail.com18-Feb-08 1:03
Memberdivya.hyd@gmail.com18-Feb-08 1:03 
Generaljavascript and MVC paradigm Pin
volkan.ozcelik5-Oct-05 2:11
Membervolkan.ozcelik5-Oct-05 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.