Hiermenus Go Forth, XVIII - DHTML Lab | 5 | WebReference

Hiermenus Go Forth, XVIII - DHTML Lab | 5

Logo

Hiermenus Go Forth, XVIII:
Version 4.0.11 - The Complete Script (Full-Window)



Improved JavaScript URL Execution

Menu items can execute JavaScript statements if a javascript: URL is specified. See Column 38 and FAQ #6.

The function that executes when an item is clicked is HM_f_LinkIt:

function HM_f_LinkIt() {
    HM_f_HideAll();
    if (this.linkText.indexOf("javascript:")!=-1) eval(this.linkText)
    else location.href = this.linkText;
}

Notice that the first statement in HM_f_LinkIt hides all visible menus. This statement was included as a courtesy to users, to indicate that their intention had registered.

This statement makes sense when the user expects to navigate to another page upon item click, but may be disconcerting if a javascript: URL is associated with the item. Not all javascript: URLs will overwrite the page. The great majority will not. They may execute a function or just a statement. There is no reason for the menu to disappear. The user should be able to continue navigating the menu tree after statement execution, without having to re-display the menu.

The HM_f_LinkIt has been changed in Version 4.0.11 to read:

function HM_f_LinkIt() {
    if (this.linkText.indexOf("javascript:")!=-1) eval(this.linkText)
    else {
        HM_f_HideAll();
        location.href = this.linkText;
    }
}

Authors can now use javascript: URLs without confusing users.

This modification was suggested by a reader whose name I have misplaced. My apologies to him.

Permanent Menus and Window Resize

In Version 4.0.9, we introduced dynamic menu repositioning upon window resize. Repositioned menus were also kept within browser window boundaries. We excluded from this behavior all menu trees with a permanent top-level menu, since permanent menus are not constrained by the window dimensions. Neither are child menus that appear directly below a permanent horizontal top-level menu.

However, child menus that are not specifically positioned should remain within the browser window. Version 4.0.11 ensures that they do.

Files Changed in Version 4.0.11

You will need to overwrite previous versions of the above files to upgrade to 4.0.11

On the next page, the sample page included in the download.


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: May 30, 2001
Revised: May 30, 2001

URL: http://www.webreference.com/dhtml/column54/4.html