spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column21 / addendum9
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Logo

Hierarchical Menus Ver. 3 - Addendum IX (v3.09)
enabling menus for IE5 Macintosh


Let's first try to fix the menu element size. Why the last menu has bad vertical sizing cannot be logically traced in the script. We never set the size. The vertical size is determined by the content.

If we try to do some simple debugging, like determining what IEMac thinks the vertical size is (by displaying the offsetHeight or scrollHeight properties of the menu element in an alert(),) we discover that the values are correct. In fact, if we interrupt the script with an alert(), the menu size values are correct, and the menus are displayed properly. This could only mean that there is a speed problem or bug. The height of the element is not updated fast enough, possibly. Or maybe my particular Mac is not fast enough. Whatever the reason for the problem is, we can fix it by brute force by assigning a height to the menu elements.

In the menuSetup() function, we have the statement below:

function menuSetup(hasParent,openCont,openItem) {
    ...
    if (NS4) {
        ...
    }
    else {
        ...
        this.fullHeight = this.scrollHeight;
        ...
    }
}

This statement determines the height of the menu element (this.scrollHeight) and stores it for future use in a custom property (this.fullHeight) used to position displayed menus within the browser window in the keepInWindow() function. We also found that the scrollHeight property was not updated in time for this assignment, but that the offsetHeight property was. For our purposes these properties are interchangeable, so we make these modifications to the function:

function menuSetup(hasParent,openCont,openItem) {
    ...
    if (NS4) {
        ...
    }
    else {
        ...
        this.fullHeight = this.offsetHeight;
        if(isMac) this.style.pixelHeight = this.fullHeight;
        ...
    }
}

We determine the real height of the element, then we size the element by assigning this value to the element's style using the pixelHeight property, if a Mac is being used.

Try the menus again with the modification in place:

Menu Example 1:

Menu Example 2:

 
Menu 1
Menu 2

Ok, we're getting the vertical size, but the horizontal size of the first menu is too wide, and we still have no display of items.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: June 16, 2000
Revised: June 16, 2000

URL: http://www.webreference.com/dhtml/column21/addendum9/3.html