JavaScript Cases: Setting JS Globals


Menu Expand/Collapse Menu

The same java script is used through the site to: (1) slide the main menu, (2) expand/collapse submenus, and (3) highlight the selected topic. That is accomplished by a script tag with the src="Menu.js".

Any settings used by the java script that are page specific must be set in a prefixing script tag. In this case sSubMenu_Name is set to either null or the submenu ID (remember null will do nothing and a submenu name will toggle the status of the submenu).

This was a little tricky because any settings placed in the script block with the src set, are placed at the end of the script, hence can't be used correctly in the src java script. Globals must be placed in a separate script block preceding the src script block as demonstrated above.

JScript Cases