DHTML Lab: HierMenus CENTRAL: Version 5 Setup - Step 5 | WebReference

DHTML Lab: HierMenus CENTRAL: Version 5 Setup - Step 5

V5 Setup Instructions
Step 5 of 6


Return to Step 4Step 5 of 6Go to Step 6
Place the menu loading script somewhere in your page. This script will conditionally load HM_Arrays.js and HM_Loader.js depending on the browser's capabilities.

By now, you should have created your external array file (step 4), customized the loader script (step 2), added the dummy function declarations to your HTML page (step 1), and optionally added page specific parameters to your page (step 3). Your page now requires one final script that will retrieve the loader file, which will in turn load the arrays and HierMenus script and launch the program. Include the following script somewhere in your HTML page, after the page specific parameters, if you've included them. Since the script writes new elements into your HTML page, be sure that you place the script somewhere outside your page's content (i.e., avoid placing this script between paragraph tags, or table tags, etc.). Since the script can go anywhere, we recommend placing it near the end of the page; right before the closing BODY tag. This way, the loading of your page content will not be delayed by the loading of the HierMenus script.

Note that in cross-frames implementations, this script should be placed in your navigation page, not your actual content pages; since you want the scripts to only be loaded once for your frameset and not with each new page load (and because that's the way HierMenus is designed).

<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>

The SRC attribute should point to the correct location for the HM_Loader.js script. In the example above, HM_Loader.js is in the same sub-directory as your page. If you keep your external scripts in a special directory, make sure the SRC attribute is modified accordingly. For example, if you created a hiermenus directory as we discussed back in step2, then you would modify the above code snippet as follows:

<SCRIPT LANGUAGE="JavaScript1.2"
        SRC="/hiermenus/HM_Loader.js"
        TYPE='text/javascript'></SCRIPT>

Remember that HM_Loader.js is the file you configured in step 2.

Special note about load and unload handlers: HierMenus takes care to preserve the state of any load or unload handlers defined earlier in the page by other JavaScript code, or directly in the body tag of the document. However, HM can only preserve these settings if it already knows about them; i.e., when the other scripts set the handlers before HM itself is loaded. Therefore, we recommend that HM be loaded as the last script on each page. If it is not, then it is possible that other scripts can set the load or unload handlers directly, overriding HM's settings and not allowing HierMenus to create or display its menus. If you don't understand what all of this means, then it probably doesn't apply to you.

If all of your top-level menus are set to be permanently visible, then congratulations: you're done! You are now ready to test your completed page.

If you created some top-level menus that you need to appear when existing page links are clicked or rolled over with the mouse, then proceed to the next step to finish your HierMenus setup.

Return to Step 4
Step 5 of 6
Go to Step 6

Produced by Peter Belesis and

Created: April 22, 2003
Revised: August 28, 2003

URL: https://www.webreference.com/dhtml/hiermenus/instructions/step5.html

Justtechjobs.comFind a programming school near you






Online Campus Both