The idea behind the Menu component is simple, and very much in line with
the ideals of object orientation. You simply make reference to a canned
JavaScript (.js) file from a one-line <SCRIPT> tag in the HEAD section
of your page then, later, call on it when you want to create your menu
object. When creating that object, you define menu entries
(specifically, the strings that represent menu options) as members.
Then, you call a function -- also defined in the imported library file
-- when you want the menu to pop up in the user's browser window.
So, to establish a connection to the library (which you can download
from the link at the end of this article, and use free of charge), you
make a quick call from a SCRIPT element, like this:
<SCRIPT LANGUAGE="JavaScript1.2" SRC="menu.js"></SCRIPT>
That assumes that menu.js is stored in the same directory on the Web
server as the document in which the line above appears. Having done
that, you can build your menu object (entries, followed by the links
they call) and use the writeMenus() method to record the menu object in
the CSS stylesheet that defines its appearance on the page (the library
handles the details out of sight; don't worry about the CSS stuff too
much):
<SCRIPT LANGUAGE="JavaScript1.2">
var popupMenu = new Menu();
popupMenu.addMenuItem("News",
"location='http://www.drudgereport.com'");
popupMenu.addMenuItem("Tech", "location='http://www.itworld.com'");
popupMenu.addMenuItem("Miscellaneous",
"location='http://www.davidwall.com'");
myMenu2.writeMenus();
</SCRIPT>
Then, when you want to display the menu you've defined, invoke the
showMenu() method. Usually, you'll call that method in response to a
click on a graphic that represents the "menu bar" entry for the menu, or
perhaps a mouseOver event on some kind of outline entry.
This article contains more detailed information about the library, and
includes a download link:
http://developer.netscape.com/viewsource/smith_menu/smith_menu.html
Also, if you haven't checked out Mozilla 1.0 yet, have a look:
http://www.mozilla.org/releases/stable.html_