84Part IIJavaScript TutorialFigure 8-1:The (Web hosting domain names) top-level browser object model
84Part IIJavaScript TutorialFigure 8-1:The top-level browser object model for all scriptable browsers. The window ObjectAt the very top of the object hierarchy is the windowobject. This object gains that exaltedspot in the object food chain because it is the master container for all content you view in theWeb browser. As long as a browser window is open even if no document is loaded in thewindow the windowobject is defined in the current model in memory. In addition to the content part of the window where documents go, a window s sphere ofinfluence includes the dimensions of the window and all of the stuff that surrounds the con- tent area. The area where scrollbars, toolbars, the status bar, and (non-Macintosh) menu barlive is known as a window s chrome. Not every browser has full scripted control over thechrome of the main browser window, but you can easily script the creation of additional win- dows sized the way you want and that have only the chrome elements you wish to display inthe subwindow. Although the discussion about frames comes in Chapter 11, I can safely say now that eachframe is also considered a windowobject. If you think about it, that makes sense becauseeach frame can hold a different document. When a script runs in one of those documents, itregards the frame that holds the document as the windowobject in its view of the object hierarchy. As you learn in this chapter, the windowobject is a convenient place for the document objectmodel to attach methods that display modal dialog boxes and adjust the text that displays inthe status bar at the bottom of the browser window. A windowobject method enables you tocreate a separate window that appears on the screen. When you look at all of the properties, methods, and event handlers defined for the windowobject (see Chapter 16), it should beclear why they are attached to window objects visualize their scope and the scope of abrowser window. Accessing window properties and methodsYou can word script references to properties and methods of the windowobject in severalways, depending more on whim and style than on specific syntactical requirements. The mostlogical and common way to compose such references includes the windowobject in thereference: window.propertyNamewindow.methodName([parameters]) windowdocumentnavigatorscreenhistorylocation