DHTML Lab - dhtmlab.com - Hierarchical Menus Ver. 3 - Addendum X (v3.10) | 3 | WebReference

DHTML Lab - dhtmlab.com - Hierarchical Menus Ver. 3 - Addendum X (v3.10) | 3

Logo

Hierarchical Menus Ver. 3 - Addendum X (v3.10)
quieter menus for Navigator


Menu items will change color in Navigator if the in-page parameter, NSfontOver is set to true. This parameter was introduced in Version 3.0. This is how we described its function then:

NSfontOver
Netscape Navigator does not support dynamic font color change. We can "fake" a color change, however, by replacing the complete contents of a positioned element, changing only the font color. Since this method can slow a system down, it is included as an option. Set to true, for NS4 mouseover font color change; false for no change. IE4 will change the font color to the value of overFnt, regardless of this parameter's value.

In Version 3.01, after feedback from Unix users, we realized that this constant layer content updating was stable only on Windows and Macintosh. We therefore included the following line in our external script, hierMenus.js:

if (!isWin && !isMac) NSfontOver = false;

Consequently, users with Navigator for Unix do not get a font color change.

Layers and document.write()

Upon item rollover, if NSfontOver is true, we update the item using document.write():

if (NSfontOver) {
    itemIdentifier.document.write(stringToWrite)
    itemIdentifier.document.close();
}

The document.write() method for layers, in Navigator, works as follows:

  1. The string argument of document.write() is exported as a text file to the browser's cache on your hard disk.

  2. The text file is read back and the contained HTML rendered in the layer.

Experts
Experts



If you are using Navigator, try the one-item menu above. You'll notice the disk access every time an update occurs. This inefficient method of writing into layers not only produces unwarranted disk activity, but creates unwanted cache files.

This insight into how document.write() works in layers was provided by my colleague Giorgio Braga, who has also created an ingenious workaround that avoids the disk-cache problems. Fodder for a future Diner article.

He also reminded me, after Version 3.09 was published, that I had still not addressed the problem:

"You know very well that Navigator can handle thousands of layers in a single page with no problem, but may choke with too many document.write's. Fix this problem now before moving on to Version 4."

And so I made a simple modification that, admittedly, should have been made long ago.


Produced by Peter Belesis and

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

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