O'Reilly logo

JavaScript® Bible, Sixth Edition by Danny Goodman, Brendan Eich, Michael Morrison

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

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 ...

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