376Part IIIDocument Objects ReferenceNavigator 4 promoted these elements (Web site designers)
376Part IIIDocument Objects ReferenceNavigator 4 promoted these elements to first-class objects contained by the windowobject. Navigator 6 added one more feature, called the directories bar a frame-like device that canbe opened or hidden from the left edge of the browser window. At the same time, however, NN6+/Mozilla browsers no longer permit hiding and showing the browser window s scroll- bars. Chrome objects have but one property: visible. Reading this Boolean value (possiblewithout signed scripts) lets you inspect the visitor s browser window for the elements cur- rently engaged. Changing the visibility of these items on the fly alters the relationship between the inner andouter dimensions of the browser window. If you must carefully size a window to display con- tent, you should adjust the chrome elements before sizing the window. Before you startchanging chrome visibility before the eyes of your page visitors, weigh the decision carefully. Experienced users have fine-tuned the look of their browser windows to just the way they likethem. If you mess with that look, you may anger your visitors. Fortunately, changes you maketo a chrome element s visibility are not stored to the user s preferences. However, thechanges you make survive an unloading of the page. If you change the settings, be sure youfirst save the initial settings and restore them with an onunloadevent handler. The Macintosh menu bar is not part of the browser s window chrome. Therefore, its visibilitycannot be adjusted from a script. ExampleIn Listing 16-6, you can experiment with the look of a browser window with any of the chromeelements turned on and off. To run this script, you must either sign the scripts or turn oncodebase principals (see Chapter 46 on the CD-ROM). Java must also be enabled to use thesigned script statements. As the page loads, it stores the current state of each chrome element. One button for eachchrome element triggers the toggleBar()function. This function inverts the visible propertyfor the chrome object passed as a parameter to the function. Finally, the Restore buttonreturns visibility to their original settings. Notice that the restore()function is also calledby the onunloadevent handler for the document. Also, if you load this example into NN6+, non-fatal script errors occur when the scrollbars are turned on or off. Listing 16-6:Controlling Window Chrome