Hiermenus Go Forth, XXI - DHTML Lab | 4 | WebReference

Hiermenus Go Forth, XXI - DHTML Lab | 4


Logo

Hiermenus Go Forth, XXI:
Version 4.0.14 - The Complete Script (Full-Window)



Netscape 6.1 cont'd

No, it is not a Mozilla bug.

The broken display of HM-enabled pages was of concern to the Mozilla community, and discussed on Bugzilla, when 0.9.3 was in development. See:

Bugzilla Bug 90617 -- HierMenus no longer working

Many thanks to Markus Hübner and Bob Clary for bringing the proposed new behavior to my attention.

The Behavior Change

In Netscape 6.0, the DOMobject.offsetLeft and DOMobject.offsetTop properties stored values different from those found in Internet Explorer. That is:

PropertyInternet ExplorerNetscape 6.0 (Mozilla 0.9.2-)
DOMobject.offsetLeftpixel distance from containing element (offset parent) leftpixel distance from page left (page X)
DOMobject.offsetToppixel distance from containing element (offset parent) leftpixel distance from page top (page Y)

These properties are used in HM to determine a parent menu's position on the page when positioning a child menu adjacent to it. All HM versions assumed the behavior differences between IE and NS6 when calculating the child menu positions in the HM_f_ShowChild() function:

function HM_f_ShowChild(){
    if(!this.child) {
        ...
    }
    if (this.tree.PositionUnder && (this.menu == this.tree.treeParent)) {
        ...
    }
    else {
        if(HM_IE5M) {
            ...
        }
        else {
            this.oL = (HM_IE) ? parseInt(this.menu.style.left) : -HM_BorderWidth;
            this.oL += this.offsetLeft;
            this.oT = (HM_IE) ? parseInt(this.menu.style.top) : -HM_BorderWidth;
            this.oT += this.offsetTop;
        }
        ...
    }
    ...
 }

The Mozilla development community decided to change the values stored in these properties for Mozilla 0.9.3...

"...to bring Mozilla into closer agreement with Internet Explorer's implementation of the properties."

In HM Version 4.0.14, therefore, we check for newer Mozilla installations (Netscape 6.1, Mozilla 0.9.3 and all other Gecko-based browsers) using the date stored in the navigator.productSub property, and tell HM that these browsers use IE-conformant position property values:

HM_IEpos = HM_IE || (HM_NS6 && parseInt(navigator.productSub)>=20010710);

And we've modified HM_f_ShowChild() accordingly:

function HM_f_ShowChild(){
    if(!this.child) {
        ...
    }
    if (this.tree.PositionUnder && (this.menu == this.tree.treeParent)) {
        ...
    }
    else {
        if(HM_IE5M) {
            ...
        }
        else {
            this.oL = (HM_IEpos) ? parseInt(this.menu.style.left) : -HM_BorderWidth;
            this.oL += this.offsetLeft;
            this.oT = (HM_IEpos) ? parseInt(this.menu.style.top) : -HM_BorderWidth;
            this.oT += this.offsetTop;
        }
        ...
    }
    ...
 }

This behavior change might make future coding easier for authors, but it means that users will have to upgrade their browsers or all code needs to have conditionals added to accommodate both the old and new behaviors.

Only HM Version 4.0.14 (and all future versions) will work correctly with both Netscape 6.0 and 6.1 on pages that have menu trees with more than one level.



On the next page, a minor fix.


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: August 10, 2001
Revised: August 10, 2001

URL: http://www.webreference.com/dhtml/column57/3.html