Submit FAQs Awards Usage Terms Contact
Categories
Partners
DaniWeb is an exciting community for web developers, Internet marketers, and technology enthusiasts.
Other Sections
Sweet Ads
Compatibility
Bookmark online:

FF1+ IE5+ Opr7+

AnyLink Drop Down Menu

Author: Dynamic Drive

Note: Updated August 2nd 05': Added border around each menu item, improved menu positioning behaviour.

Description: This is an extremely versatile drop down menu script for ordinary links on your page, including image links. It can be activated either onMouseover or onClick. The menu intelligently determines whether the dropped menu is too close to the browser's edge, adjusting its positioning so it's always in view.

This script works in all the major DHTML browsers- IE4+, NS6+, and Opera7+. You can specify a valid default URL for each link for other browsers to navigate to. Cool!

Demo:

Web Design | Technology | News Sites (onclick)


Directions Developer's View

Step 1: Insert the following style sheet and script into the <head> section of your page:

Select All

Step 2: Having done the above, all that's left is setting up your link(s) so a menu drops down. The below sample HTML demonstrates two links, one with the menu dropping down onMouseover, and the other, onClick:

Select All

The dropdownmenu() function accepts 4 parameters as shown:

dropdownmenu(this, event, menuarray, 'width')

Only customize the last two parameters (menuarray and 'width'), where:

3) Menuarray- The array contents you wish the menu to display (see code of Step 1).

4) Width- The width of the menu (pass in "" if you simply wish to use the default menu width).

And that's about it!

More information on customizing the menu

Inside the code of Step 1, a few items are available for customization. Firstly, the style sheet can be used to add additional visual styling to the menu, excluding default menu width and background color, which are controlled by two variables within the script that follow. You can also specify the disappearance delay of the menu when the mouse moves out of it.

Recent Change Log

  • Updated August 2nd 05': Added border around each menu item, improved menu positioning behaviour. For the later, if a menu doesn't have the space to drop down nor up, it is positioned at the top edge of the browser window instead.
  • Updated March 20th 05': Added hover effect over each menu item