Section 25.168. IFrame: an iframe in an HTML document


25.168. IFrame: an <iframe> in an HTML document

DOM Level 2 HTML: Node Element HTMLElement IFrame

25.168.1. Properties

As explained in the following Description, iframe elements can be accessed as IFrame objects or as Window objects. When accessed as IFrame objects, they inherit properties from HTMLElement and define the additional properties below:


Document contentDocument

The document that holds the content of the <iframe>.


String src

The URL from which the iframe's content was loaded. Setting this property causes the iframe to load a new document. This property simply mirrors the src attribute of the HTML <iframe> tag.

In addition to these properties, the IFrame object also defines the following properties, which correspond directly to HTML attributes of the <iframe> tag:

Property

Attribute

Description

deprecated String align

align

Alignment with respect to inline content

String frameBorder

frameborder

Set to "0" for borderless frames

String height

height

Height of the viewport in pixels or percent

String longDesc

longdesc

The URL of a frame description

String marginHeight

marginheight

Top and bottom frame margin, in pixels

String marginWidth

marginwidth

Left and right frame margin, in pixels

String name

name

The name of the frame, for DOM Level 0 lookup and form and link targets

String scrolling

scrolling

Frame scroll policy: "auto", "yes", or "no"

String width

width

Width of the viewport in pixels or percent


25.168.2. Description

Except for small differences in their HTML attributes, <iframe> elements behave very much like <frame> elements in client-side JavaScript. <iframe> elements become part of the frames[] array of the containing window. When accessed through that array, they are represented by Window objects, and the properties listed earlier do not apply.

When an <iframe> element is accessed as a document element by ID or tag name, it is represented by an IFrame object, with the properties shown previously. Use src to query or set the URL of the <iframe>, and use contentDocument to access the contents of the iframe. Be aware, however, that the same-origin policy (see Section 13.8.2) may prevent access to the contentDocument.

25.168.3. See Also

Frame, Window; Chapter 14




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

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