O'Reilly logo

Learning JavaScript by Shelley Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The window Object

The browser window encompasses the entire browser environment, including parts of the window “chrome” (the part of the browser that surrounds the document), the actual web page, and even the user’s experiences.

The window object is global and always present even if its presence is implicitly, rather than explicitly, stated. In previous chapters we’ve used functions such as alert and eval, and these functions may seem “independent” of any object model. However, they’re implicitly a part of the window object—as is the document and other second-level objects, global variables, and other objects not associated with any other object within an object model.

The window has interest beyond being just a parent to all other elements. Through it you can manually set the status in the status bar of the browser, open a new window, resize one that’s already open, and then close it again. This is handy if you’re providing separate windows for help or additional information, though with the growing popularity of DHTML and Ajax, much of this now occurs within a document rather than a separate window.

The window object methods and properties fall into four categories: creating and managing new windows, manipulating the behavior of existing windows, serving as timers, and being the parent of the other objects in the BOM.

For the first category, creating new windows, three methods provide quick pop-up windows (each for a specific purpose), while a fourth can create a window with as much, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required