|
home / documentation / reference / hm_scriptdir
HM_ScriptDir
- Description:
- The server directory (folder) where the HierMenus scripts are stored.
- Value:
- String, empty string (""), or JavaScript expression that returns a String/empty string.
- Applies To:
- Globally.
- Browser Compatibility:
- HM_ScriptDir is supported in all browsers.
- Comments:
- HM_ScriptDir is the server directory, specified as a valid
URL, of the location on your Web server where the HierMenus scripts are stored.
Typically, the HM_Loader.js file is also stored in this directory, though
that is not strictly necessary.
HM_ScriptDir is a global variable that is set in the HM_Loader.js
file (and, if you are using the alternate cross-frames loading method, the
HM_NavFrameLoad.js file). It is not set in the configuration file as other
configuration parameters are, which explains why it is set using a standard JavaScript
assignment statement (via the = sign). The reason for
this is because HierMenus needs to know the value of HM_ScriptDir
before the configuration file is loaded. See the examples below.
When set to something other than the empty string (""),
HM_ScriptDir must always end with a trailing slash (/).
If HM_ScriptDir is set to the empty string, as it is by
default, then HierMenus will assume that the various execution scripts (HM_ScriptDOM.js,
HM_ScriptOPR.js, HM_NavFrameDOM.js, etc.) exist in the same directory
that the HTML page that is calling them is in. This means that, with HM_ScriptDir
set to the empty string you would need to place copies of all the HierMenus scripts in
each directory of your server (or at the very least, each directory that contains an
HTML page that will be displaying menus). This approach is not advised.
Rather, you should create a a single directory on your server where all your HierMenus
scripts will be stored, and then set HM_ScriptDir to point to that directory.
If you use an absolute (including the domain name) or root-relative (beginning with a
slash) pathname in HM_ScriptDir, then HierMenus will be able to properly find the
scripts no matter where the HTML page that loads them is. For example, assuming
your domain is called www.mydomain.com and you've stored the HierMenus
scripts in a folder in your Web document root called hm/scripts, then
either of these settings for HM_ScriptDir is recommended:
HM_ScriptDir="http://www.mydomain.com/hm/scripts/";
HM_ScriptDir="/hm/scripts/";
In the HM_Loader.js file, you may note that the default setting for
HM_ScriptDir looks a little cryptic:
if(typeof(window.HM_ScriptDir)=="undefined")
HM_ScriptDir = "";
Though admittedly verbose, setting the parameter in this manner (with the if...
logic on the line just prior to the setting of the actual parameter) allows you
to override this setting on a page by page basis if you should choose to do so at
a later time. i.e., The logic above basically says "if HM_ScriptDir is not
already set, set it now." If you know that you will never be overridding HM_ScriptDir
on any of your pages, then you can remove the if... line that precedes the
HM_ScriptDir setting. We recommend, however, that you leave it as is so that
you can take advantage of the feature at a later time if need be.
- Examples:
// Ok:
HM_ScriptDir = "http://mydomain.com/hm/scripts/",
HM_ScriptDir = "/hm/scripts/", // Web server root relative address
HM_ScriptDir = "myscript/", // relative to page (not recommended)
HM_ScriptDir = "", // same as page (not recommended)
HM_ScriptDir = (window.useVerbose)?"/hm/verbose/":"/hm/opt/",
// if the user defined variable "useVerbose" is true,
// then use the scripts located in "/hm/verbose/";
// otherwise use the scripts located in "/hm/opt/"
// Incorrect:
HM_ScriptDir = http://mydomain.com/hm/scripts/,
// strings must be quoted
HM_ScriptDir = " ",
// no spaces allowed in the empty string
HM_ScriptDir : "http://mydomain.com/hm/scripts/",
// must use = sign (not colon)
HM_ScriptDir = '(window.useVerbose)?"/hm/verbose/":"/hm/opt/"',
// no quoted expressions
- Default:
- ""
- See Also:
-
HM_ConfigDir,
HM_ConfigFiles,
HM_ConfigType,
HM_FramesEnabled,
HM_ImageDir
|