 |
Please Note:
HierMenus is protected by copyright laws. Use of the HierMenus code requires a paid licensing agreement.
|
|
 |

|
 |
 |
|
home / documentation / reference / hm_onlink
HM_OnLink
- Description:
- The custom (user defined) method that is called when a new
page is about to be loaded as the result of clicking a menu item.
- Value:
- JavaScript function.
- Applies To:
- Menu Items.
- Browser Compatibility:
- HM_OnLink is supported in all browsers.
- Parameters:
- (itemEl)
itemEl is the HTML element for the menu item
- Comments:
- HM_OnLink is a HierMenus Menu Event Hook; a
means for you to execute your own custom JavaScript code from within normal
HierMenus processing. All menu event hooks expect to be set to the name of
a custom function (typically of your own creation, although the HM_Loader.js
file contains some custom functions designed for use with event hooks), a
function literal, or a dynamically generated function.
The function you create for use with this menu event hook should be designed
as a method of the item object, i.e., the internal item object that HierMenus
creates to track the various unique parameters of the item itself. Thus, the
this keyword, within the context of your custom function, refers
directly to the item object.
The item object (referred to by this) is not the
same as the item element. The item object is the internal structure
that HierMenus uses to track various pieces of information specific to this
item. The item element is the actual HTML page element that represents
the item itself. You access the item object via the this keyword
within your custom method; you access the item element via the first parameter
passed to the function.
HM_OnLink is called when HierMenus is about to load a new page
as the result of a menu item click; i.e., when the item's LinkURL
is about to be followed. Unlike other event hooks, you can cancel the HierMenus
behavior (i.e., you can prevent the link from actually being loaded) by
returning false from your HM_OnLink method. If HM_OnLink
returns a value of false (or any other value that converts to
false), then HierMenus will not attempt to load LinkURL.
For further usage and implementation information, see the mini-tutorial
Menu Event Hooks.
- Example Method:
// Do not process a link if a
// particular global var is set
function HM_fc_ItemLink() {
return ((window.doHMLinks)?true:false);
}
- Example Settings:
// Ok:
HM_OnLink:HM_fc_ItemLink,
HM_OnLink:null, // remove hook for this item
// Incorrect:
HM_OnLink:"HM_fc_ItemLink",
// do not quote function names here
HM_OnLink:"null",
// do not quote null here
- Default:
- null
- See Also:
-
HM_OnMove,
HM_OnVisibilityToggle,
HM_OnCreateMenu,
HM_OnMenuCreated,
HM_OnItemHilite,
HM_OnBuildMenus,
HM_OnItemClick,
HM_OnItemHover,
HM_OnCreateItem,
HM_OnItemCreated,
HM_OnMenuOver,
HM_OnMenuOut,
HM_OnItemOver,
HM_OnItemOut,
setTrans,
killTrans,
Menu Event Hooks Mini-Tutorial
|
|