Home > Articles

  • Print
  • + Share This
This chapter is from the book

Using window Objects

At the top of the browser object hierarchy is the window object, which represents a browser window. You’ve already used at least one method of the window object: alert(), which displays a message in an alert box.

A user might have several windows open at a time, each with its own distinct window object, since different documents will presumably be loaded in each window. Even if the same document is loaded into two or more windows, they are considered distinct window objects because they are in fact distinct instances of the browser. However, when you reference window.document (or just document, as the window object is the default parent object so we don’t need to explicitly refer to it) in your JavaScript, the reference is interpreted to be the window currently in focus—the one actively being used.

The window object is the parent object for all the objects we will be looking at in this chapter. Figure 6.2 shows the window section of the DOM object hierarchy and a variety of its objects.

FIGURE 6.2

FIGURE 6.2 The window section of the DOM object hierarchy, and some of its children.

  • + Share This
  • 🔖 Save To Your Account