More Info


You are in: home > javascript > drop down menu tutorial >

There is a newer drop-down menu tutorial at:
http://www.aspandjavascript.co.uk/javascript/drop_down_menu_tutorial_version_2/

click here to go to the new drop down menu tutorial

Unfortunately, support can no longer be offered for this tutorial

Cross Browser Drop-down Menus

4. Putting menus together

So far we've only had one menu - not much use really. Here's something a bit more useful:

The revised code is below:

We've added 2 more menus and named all three very carefully. The menus are called "myMenu1", "myMenu2" and "myMenu3". The images used for Netscape 4.x to position them properly are called "myImg1", "myImg2" and "myImg3".

The "showMenuTest" function has also changed. It now accepts another parameter - "menuNumber" - which is used to show the correct menu. And it calls the "hideAllMenusTest" function to get rid of any previously shown menus.

There are are a couple of other new lines of code:

  • numMenus = 3;
  • document.onmouseover = hideAllMenusTest;

The first stores the number of menus. The second sets up an event handler that calls another new function ("hideAllMenusTest" - which unsurprisingly hides all the menus) whenever the mouse is put over the body of the page.

One final new trick is: onmouseover="event.cancelBubble = true;" which stops mouseover events being passed to the body of the page if the mouse is over one of our menus.

More Netscape Problems?

Guess what? The code doesn't work quite right on Netscape! The "document.onmouseover" handler doesn't do the job it's supposed to do. In the next section We'll add some more code to hide menus that are no longer in use that will work properly with Netscape 4.x


<< Part III: Menu Placement Part V: Hiding Menus >>

Get the code:
[Drop-down version] [Side-menu version] [Cascading version]

If you like Javascript Cascading Drop-down Menu ,
please rate it! @ ScriptSearch.com
Rate Our Program
@ HotScripts.com
Rate Our Program
@ AllTheScripts.com





 © James Austin 2002-05 Web site design by James Austin