asp.net.ph

Skip Navigation Links

IFRAME Element | IFRAME Object

Language References


Defines the contents and appearance of an inline frame. HTML 4, 5

HTML Syntax

Remarks

The IFRAME element allows authors to insert a frame with its own contents within an HTML page. The IFRAME functions as a document within a document, or like a floating FRAME.

The IFRAME can display a distinct HTML document. The element’s src attribute specifies the initial document the IFRAME will contain. Authors can also provide alternate content, written between the IFRAME start and end tags, for browsers that do not support frames or are configured not to display frames.

The IFRAME is normally assigned a name to identify and reference the frame. This name may be used as the target of subsequent links.

Authors can also specify the appearance of an IFRAME, using the element’s rendering attributes. Unlike frames, an IFRAME can not be resized.

Members

IFRAME Members

Example

For browsers that support frames, the following example renders an inline frame containing the file sample.html.

<iframe src="sample.html" scrolling="auto" width="400" frameborder="1"></iframe>

The following provides alternate content which should be displayed only by browsers that do not support frames.

<iframe src="sample.html" ... >Your browser does not support frames or 
   is currently configured not to display frames. To view the related document, 
   click <a href="sample.html">here</a></iframe>
Notes on DOM Access

Properties of an IFRAME object can be accessed through the object model of the page where the IFRAME resides. Typical notation is:

IE4 and later

document.all['iframeID'].property

IE5 and NN6

document.getElementById ( 'iframeID' ).property

Assuming for example that we have an IFRAME object with an id=iframe1. To access the border style of the IFRAME:

document.getElementById ( 'iframeID' ).style.border;

On the other hand, access to the objects of the source document of the IFRAME is provided through the frames collection. This allows authors to read or write to elements contained in the IFRAME. Typical notation is:

document.frames ( 'iframeID' ).document.object.property

For example, to access the backgroundColor of the BODY object in the IFRAME:

document.frames ( 'iframe1' ).document.body.style.backgroundColor = "khaki";

The following returns a collection of all elements of the document contained in the IFRAME, using the documentElement object.

var els = document.frames ( 'iframe1' ).document.documentElement.childNodes
See Also

FRAME   frames   Using Frames and Framesets



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note