Q:
How do we create a DHTML drop-down menu?
Answer
- In order to create a DHTML drop down menu we need JavaScript API. The API (Application Programming Interface) consists of core set of cross-browser JavaScript functions to make DHTML programming easy and quick. This API enables moving and hiding page elements as well as acts as getter and setter of page elements attributes.
- Second we define on image object and off image object and string containing the URL of the "off" version.
- Then we create the menu items, label items and sub-menu items. If we wish we can use images also.
- Then we need to define our own global variables that will be used by the menu. Using global goes against oops design but makes sharing data easier.
- Create the menubar object, adding the menu labels and writing menubars.
- Create menu object, adding menu items and writing menus.
- Hiding and displaying the menus and attaching stylesheet.
View answer
Workspace
Report Error
Discuss