Working with Frame, Frameset, and Iframe Objects


A frame is a fractional part of a window. Frames usually come in groups and are all contained in a frameset object. Each frame is considered a separate window to the browser, and a different HTML document can be loaded into each. An iframe is a frame that occurs within the natural flow of the rest of the page. An iframe can also have a completely different HTML document than the rest of the page.

Frames and iframes can be considered separate windows when you are writing your code. This, of course, might cause some confusion because even though a Web page can have multiple frames and iframes, they are technically all contained on the same window. Following is the syntax for referencing a frame object in Internet Explorer:

 WindowHandle.document.all.frameID 

The windowHandle is the handle to the window that contains the frame. This value can be one of the values returned from window.open(), as mentioned above, or can be parent or top (the parent and top properties will be discussed later in this chapter).

Referencing an iframe object is slightly easier than referencing frames because there is no ambiguity about the window it is contained on. Here is the syntax for Internet Explorer:

 Document.all.frameID 

Netscape browsers don't allow you to directly access frames in this way. You can, however, access frames through the frames[] collection in both browsers. Here is the syntax for doing so:

 windowHandle.frames[i] 

This technique provides cross-platform compliance, but does not provide the control that Internet Explorer alone provides. There is generally no need to reference a frameset object, but if the need arises, the frameset object can be referenced just like any other HTML element—by its ID property.




JavaScript Professional Projects
JavaScript Professional Projects
ISBN: 1592000134
EAN: 2147483647
Year: 2002
Pages: 130
Authors: Paul Hatcher

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net