Drop-down Navigation Generator Script

Published December 1st, 2006 under JavaScript, Web Development
by Mashhoor Al Dubayan

I’ve recently made a small script that you could use to automatically generate a drop-down navigation from an existing list-based navigation on your web page. The script will detect the navigation with the ID you provide, generate a drop-down equivalent and insert it within an element you specify. Choosing any option of the drop-down list would send you to its corresponding link (as seen on many sites).

To start using the script in your own page, just modify the function calls within the init function (further explanation can be found in the source code). You could generate as many drop-down navigations as you want, but you probably won’t need more than one.

Notes:

  • The script will not work with multi-level lists, because I couldn’t find a way to make a semantic multi-level drop-down list. (any suggestions?)
  • If one of your list’s elements doesn’t contain a link, the script will not work properly.
  • The script has been tested under Internet Explorer 6, Firefox 1.5/2.0, Opera 9 and Safari 2.0

Download script (sample included)

2 Responses to “Drop-down Navigation Generator Script”

  1. 1 Egor

    Nice work, Mashhoor. Just tested in Safari 2.0.4 and it appears to work without a problem, so you can add that to your compatibility list.

  2. 2 Mashhoor Al Dubayan

    Thanks Egor. :)

    (sorry for the late response, but my e-mail didn’t notify me about this comment for some reason)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>