Chapter 11. Scripting Frames and Multiple Windows

IN THIS CHAPTER

  • Relationships among frames in the browser window

  • How to access objects and values in other frames

  • How to control navigation of multiple frames

  • Communication skills between separate windows

One of the attractive aspects of JavaScript for some applications on the client is that it allows user actions in one frame or window to influence what happens in other frames and windows. In this section of the tutorial, you extend your existing knowledge of object references to the realm of multiple frames and windows.

Frames: Parents and Children

You've see in earlier top-level hierarchy illustrations (such as Figure 4-2) that the window object is at the top of the chart. The window object also has several synonyms, which stand in for the window object in special cases. For instance, in Chapter 8, you learned that self is synonymous with window when the reference applies to the same window that contains the script's document. In this lesson, you learn the roles of three other references that point to objects behaving as windows: frame, top, and parent.

Loading an ordinary HTML document into the browser creates a model in the browser that starts out with one window object and the document it contains. The top rungs of the hierarchy model are as simple as can be, as shown in Figure 11-1. This is where references begin with window or self (or with document because the current window is assumed).

Figure 11-1. Single-frame window and document ...

Get JavaScript® Bible, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.