DHTML Lab: HierMenus CENTRAL: FAQ #5 - dhtmlab.com | WebReference

DHTML Lab: HierMenus CENTRAL: FAQ #5 - dhtmlab.com

Frequently Asked Question #5

Do the HM files have to be in the same directory as the HTML page that uses them?
I want to have the files in one directory accessible from my whole site.

No they do not, and in fact we strongly recommend that you place your HM scripts and images all in a single, central directory. You can keep all your files in one directory as long as you indicate to HM where the directory is and "load" the files from this directory.

Unlike many other scripts, HM has an external script (HM_Loader.js) loading other external scripts (HMArrays.js and HMScriptxxx.js.)

HM_Loader.js is loaded into your HTML page with this tag:

<SCRIPT LANGUAGE="JavaScript1.2"

Beginning with HM version 5.0, you can tell HierMenus where to find the scripts and images on your system using the HM_ScriptDir and HM_ImageDir variables. See our Setup Instructions pages for further details, and ignore the remainder of this discussion.

In HM Version 4.x, you can edit HM_Loader.js directly to tell it where to find your script files. HM_Loader.js contains these statements (below) to load the other scripts:

if(HM_IsMenu) {
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='HM_Arrays.js' TYPE='text/javascript'><\/SCR" + "IPT>");
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='HM_Script"+ HM_BrowserString +".js' TYPE='text/javascript'><\/SCR" + "IPT>");

For example, when we ran HierMenus version 4 In HierMenus CENTRAL, the files that create the navigation menu were all stored in this directory:


With version 4 HM, every page that used HM loaded HM_Loader.js with this syntax:

<SCRIPT LANGUAGE="JavaScript1.2"

Alternately, we could of used:

<SCRIPT LANGUAGE="JavaScript1.2"

So far, so good. Most readers who have asked this FAQ load HM_Loader.js correctly.

What is not immediately obvious, however, is that the other scripts are not loaded into HM_Loader.js, but into the HTML page that originally loaded HM_Loader.js. The contents of HM_Loader.js belong to the HTML page, and therefore the path to the scripts must match the path used to load HM_Loader.js:

if(HM_IsMenu) {
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='/dhtml/hiermenus/scripts/HM_Arrays.js' TYPE='text/javascript'><\/SCR" + "IPT>");
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='/dhtml/hiermenus/scripts/HM_Script"+ HM_BrowserString +".js' TYPE='text/javascript'><\/SCR" + "IPT>");


if(HM_IsMenu) {
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='http://www.webreference.com/dhtml/hiermenus/scripts/HM_Arrays.js' TYPE='text/javascript'><\/SCR" + "IPT>");
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='http://www.webreference.com/dhtml/hiermenus/scripts/HM_Script"+ HM_BrowserString +".js' TYPE='text/javascript'><\/SCR" + "IPT>");

In HM version 4, make sure the files loaded by HM_Loader.js have the correct path and you can access them from any page on your site.

Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: June 26, 2001
Revised: April 22, 2003

URL: http://www.webreference.com/dhtml/hiermenus/faq/faq5.html

Justtechjobs.comFind a programming school near you

Online Campus Both