The
object is a collection of all of the frame windows in the current frameset. Each frame is a Frames
object in itself, and has its own Window
object to represent the HTML in the frame. This really isn’t as confusing as it might sound—it mimics the organization of frames without an object model. The top-level frame subdivides the browser window and loads separate HTML pages for each frame. Document
It can be confusing to use this property though. By default the
and Window
object that a script refers to are the Document
and Window
objects of the current frame. This means that, if we execute a script in the left-hand frame of a two-frame window, the Document
, Document
, and Window
objects the script uses will be those of the left-hand frame. Since the left-hand frame has no sub-frames, examining the Frames
property of the Count
collection will return Frames
.0
However, if we use the
(or, in this case, Top
) property of the left-hand frame’s Parent
object, we can gain access to the top-level frameset that loaded both the frames. Examining the Window
property of this Count
collection will show the expected value of Frames
, because this top-level page has loaded two frames.2
We’re giving this brief coverage here because it’s both a simple and complex topic. In the sense that the
collection has only one property, Frames
, and that it just provides access to other objects that we’ve covered before, like Count
and Window
, it is a simple object. However, the relationships between the different frames in a frameset can be complex, and to best understand how it works, we should really see some code. A more in-depth example of using frames with the object model is part of the next chapter.Document