A menu item can ordinarily do one of these two things:

  1. Open a Web page — that is, go to a certain URL; this can be done in the same window, in a new window (by specifying the target="_blank" attribute to the link, like in any HTML document) or in a named window (again, by specifying a window name as the target attribute, just like in any HTML document).
  2. Execute JavaScript code. This is done by specifying a “href” attribute that starts with "javascript:", just like in any HTML document.

The careful reader will notice that even in browsers that don't support our menu, the functionality is not lost because you are using standard HTML ways to specify the action and target of a link. That is, we are relying to—and tricking the browser about—standard HTML tags and attributes, in order to setup the menu; this has the big advantage that even in browsers that do not support our menu, the functionality of your application will not be lost.

See the source of this page in order to understand the example.

The last item from the last menu (“toggle <P>-s visibility”) introduces you to another technique: when the action of some menu item is to execute JavaScript code, you can specify wether to close the submenu or not. We are setting the value of the “retval” variable to “true” (by returning “true” from our function) and this specifies DynarchMenu that the popup should remain visible.

If we'd set “retval” to “false” (or not set it at all) then DynarchMenu will close the popup menus—it's likely that you'd want to have this default.