• home
  • forum
  • my
  • kt
  • download
  • AnyLink Vertical Menu

    Author: 2007-08-08 09:10:14 From:

    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 setting up the menu on either a regular text link or a list element (<li>):

    Select All

    The dropdownmenu() function inside the code of Step 2 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, in pixels.

    And that's about it!

    Useful Information

    As shown in the demo, this script can be associated not just with a regular link (<a>), but also other elements such as a list <li>, a table cell <td> etc. For non regular links, the trick is to make sure the element that will activate the menu has a width defined somewhere. Lets take the example of the list in the demo above:

    <ul class="navlist">
    <li><a href="#">Dynamic Drive</a></li>
    <li onMouseover="dropdownmenu(this, event, menu2, '150px')" onMouseout="delayhidemenu()"><a href="#">JavaScript Kit</a></li>
    <li><a href="#">CSS Drive</a></li>
    <li><a href="#">Coding Forums</a></li>
    </ul>

    Here instead of inserting the onMouseover code inside a standard <a> tag, we add it inside a <li> to activate the menu onMouseover. This works, but only if the <li> has a width defined for it, which if you examine the CSS of step 1, you'll see it does:

    .navlist li {
    width: 135px;
    "
    "
    }

    A width needs to be defined either for the <li> (or <ul> instead if you like) in this case, since without it, the menu has no way to know how far to display the menu to the right of the element, and typically will display the menu too far away from the element as a result. So simply remember, when using this script on elements other than a text link, make sure the element has a width defined, either explicitly, by way of an external CSS, or its container.

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      AJAX (20)
      Content Management (7)
      Cookies (4)
      Date and Time (12)
      Development (7)
      DHTML (14)
      Forms (8)
      Frequently Asked Questions (1)
      Image Display (9)
      Introduction to Javascript (5)
      Links and Buttons (4)
      Menus (2)
      Miscellaneous (5)
      Mouse Tricks (3)
      Navigation (8)
      Randomizing (4)
      Security (1)
      Text Effects (6)
      User Authentication (2)
      User Information (5)
      Windows and Frames (3)

    New

    Hot