DropDown Menu

You can easily add a beault (and CSS formatable) drop-down menu to a web with accessibility navigation based on a simple TWiki list.

Your menu HTML code will stay being a list of links (the best semantics for that). Good for google and other search bots, and good for text browsers. Some people need to navigate with the tab, because they are blind or has degenerative disease... this code enable to open sub-menus with tab focus.


You only need a list. Better if it is a TWiki list. All list items must be links, except the parents of the sub-menus like this:

<div id="some-id">
   * [[Link 1]]
   * Link 2
      * [[Link 2.1]]
      * [[Link 2.2]]
      * [[Link 2.3]]
   * Link 3
      * [[Link 3.1]]
      * Link 3.2
         * [[Link 3.2.1]]
         * [[Link 3.2.2]]
      * [[Link 3.3]]

This TWiki code makes the menu above as a big example (not really useful):

<div id="menuTeste">
   * [[Web Home]]
   * TWiki Services
      * WebNotify
      * WebIndex
      * WebSearch
      * TWiki Groups
%SEARCH{ "TWiki"
         format="         * $web.$topic" }%
      * [[TWiki.TWikiRegistration][Registration]]
   * Admin Docs
%SEARCH{ "AdminDocumentationCategory"
         format="      * $web.$topic"}%
   * [[Main.TWikiUsers][Users]]

You can see the real world using this hire:

This websites are TWiki based and the site menu uses this DropDown Menu.


  • Multiple sub-menus suport
  • Open sub-menus with mouse over or with tab focus
  • Close sub-menus with mouse out or with tab blur
  • Formatable as easy you want with CSS
  • The generated HTML code is a common TWiki list with links, best semantics for search bots and text based browsers

Not happy? Some cull feature missing? Please, make a proposal!

How to add the drop-down codebase?

To have a DropDown menu on your web add this two red lines:

  • On your CSS:
    %INCLUDE{"TWiki.DropDownMenu" section="css" MENU_ID="your-menu-id"}%
    (and you can add more css for the menu hire, to make it personal)

  • Below your menu list:
    %INCLUDE{"TWiki.DropDownMenu" section="js" MENU_ID="your-menu-id"}%

If you already use prototype.js on your TWikiWeb template, you can set DO_NOT_LOAD_PROTOTYPE="on" in the %INCLUDE% to it do not load the script again.
%INCLUDE{"TWiki.DropDownMenu" section="js" DO_NOT_LOAD_PROTOTYPE="on" MENU_ID="your-menu-id"}%

If you want to load the prototype in the <head> block (and that is better) put this line on your template:
<script type="text/javascript" src="%PUBURL%/TWiki/DropDownMenu/prototype.js"></script>
and use the DO_NOT_LOAD_PROTOTYPE="on" in the %INCLUDE%.

How can i change the menu appearance?

Think in CSS ever.

All new repeated sets, resets the old set. So... Replace everything that you want by CSS after the %INCLUDE% section css.


<style> /* <pre> disable TWiki parser */

  body {
    color: #777;
    font-family: sans-serif;

  %INCLUDE{"this topic" section="css" MENU_ID="menu"}%

  #menu ul ul a{
    padding: 3px 2px 3px 15px;
    background-color: #DCDCDC;

  #menu ul ul a.linkSubMenu {
    color: red;
  #menu ul ul a.linkSubMenu:hover {
    color: green;


linkSubMenu is the class added to the link created to open the sub-menus.

Work around IE CSS bugs: If your personalization is getting some problem with IE, don't cry. The script add a msie class on the div parent of the menu list.

So, you cam make that:

  #menu {
    /* a code for all */
  #menu.msie {
    /* a code replace for IE */
And your CSS will not break the standards as the common CSS hacks.


This AddOn is a licenced in the GPL version 2 or (at your option) a later version.

When copy this to your TWiki, don't forget to copy the prototype.js attached in this topic or a newer version from http://www.prototypejs.org

-- Contributors: AurelioAHeckert - 29 Aug 2007

Source URL: TWiki:Plugins.DropDownMenuAddOn

-- PeterJones - 18 Apr 2008

Topic attachments
I Attachment History Action Size Date Who Comment
JavaScriptjs prototype.js r1 manage 121.2 K 2008-04-18 - 11:36 PeterJones Prototype JavaScript framework, version 1.6.0
Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2008-04-18 - PeterJones
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    TWiki All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.DropDownMenu