iframe | NN 6 IE 4 DOM 1 | ||||||||||||||||||||||||
The iframe object reflects the iframe element. Be aware that, in Internet Explorer, a number of properties defined for this object have no effect on the object nor any default value, but are implemented because the element shares its internal structure with other elements that use those properties. |
|||||||||||||||||||||||||
HTML Equivalent | |||||||||||||||||||||||||
<iframe> |
|||||||||||||||||||||||||
Object Model Reference | |||||||||||||||||||||||||
[window.]document.getElementById("elementID")
|
|||||||||||||||||||||||||
Object-Specific Properties | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Object-Specific Methods | |||||||||||||||||||||||||
None. |
|||||||||||||||||||||||||
Object-Specific Event Handler Properties | |||||||||||||||||||||||||
None. |
align | NN 6 IE 4 DOM 1 |
Read/Write | |
Defines how the element is aligned relative to surrounding text content. Most values set the vertical relationship between the element and surrounding text. For example, to align the bottom of the element with the baseline of the surrounding text, the align property value would be baseline. An element can be "floated" along the left or right margin to let surrounding text wrap around the element. |
|
Example | |
document.getElementById("myIframe").align = "absmiddle"; |
|
Value | |
Any of the following alignment constant values (as a string): absbottom | absmiddle | baseline | bottom | right | left | none | texttop | top. |
|
Default | |
bottom |
allowTransparency | NN n/a IE 6 DOM n/a |
Read/Write | |
Specifies whether the iframe background can be transparent. For the background of the main document to show through both the iframe and its document, the document's background-color style attribute must be set to transparent. |
|
Example | |
document.getElementById("myIframe").allowTransparency = true; |
|
Value | |
Boolean value: true | false. |
|
Default | |
false |
border | NN n/a IE 4(Win) DOM n/a |
Read/Write | |
Although defined for the iframe element object in IE/Windows, the border property has no value nor does assigning a value affect the appearance of the element. |
borderColor | NN n/a IE 4 DOM n/a |
Read/Write | |
Although defined for the iframe element object in IE, the borderColor property has no value. Assigning a color value does draw a thin border around the iframe's rectangle on the Macintosh, but has no effect in Windows. |
contentDocument | NN 6 IE n/a DOM 2 |
Read-only | |
Returns a reference to the document object loaded into the iframe element object. Through that document object, you can access one of the document's elements via the getElementById( ) method, or access the containing window object via the document's defaultView property. For IE/Windows, use the contentWindow property to jump from iframe element object to its content. |
|
Example | |
var iframeElem = parent.document.getElementById("myIframe"); var doc = iframeElem.contentDocument; |
|
Value | |
Reference to a document node. |
|
Default | |
Current document node. |
contentWindow | NN 7 IE 5.5(Win) DOM n/a |
Read-only | |
Returns a reference to the window object generated by the iframe element. Through the window object, you can access the document object and then any one of the document's elements. For Netscape 6, use the contentDocument property to jump from iframe element object to its content. If you are trying to reach script variables or functions in the frame, the contentWindow (or W3C DOM-friendly and Netscape 6-compatible contentDocument.defaultView) provides access to the script context. |
|
Example | |
var iframeElem = parent.document.getElementById("myIframe"); var win = iframeElem.contentWindow; |
|
Value | |
Reference to a window node. |
|
Default | |
Current window node. |
dataFld | NN n/a IE 4 DOM n/a |
Read/Write | |
Used with IE data binding to associate a remote data source column name with the value of the src property. A datasrc attribute must also be set for the element. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac. |
|
Example | |
document.getElementById("myIframe").dataFld = "frameURL"; |
|
Value | |
Case-sensitive identifier of the data source column. |
|
Default | |
None. |
dataSrc | NN n/a IE 4 DOM n/a |
Read/Write | |
Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac. |
|
Example | |
document.getElementById("myIframe").dataSrc = "DBSRC3"; |
|
Value | |
Case-sensitive identifier of the data source. |
|
Default | |
None. |
frameBorder | NN n/a IE 4 DOM n/a |
Read/Write | |
This property should control whether the frame displays a border. In practice, the property has no effect on the visual appearance of an inline frame. |
frameSpacing | NN n/a IE 4 DOM n/a |
Read/Write | |
The amount of spacing in pixels between frames within a frameset. This property has no effect on an inline frame in Internet Explorer. |
height, width | NN 6 IE 4 DOM 1 |
Read/Write | |
Provide the pixel or percentage measure of the iframe element's height and width. |
|
Example | |
document.getElementById("myIframe").height = "200"; document.getElementById("myIframe").width = "500"; |
|
Value | |
Length string. |
|
Default | |
300 (width); 150 (height). |
hspace, vspace | NN n/a IE 4 DOM n/a |
Read/Write | |
Provide the pixel measure of horizontal and vertical margins surrounding an inline frame. The hspace property affects the left and right edges of the element equally; the vspace property affects the top and bottom edges of the element equally. These margins are not the same as margins set by style sheets, but they have the same visual effect. |
|
Example | |
document.getElementById("myIframe").hspace = 5; document.getElementById("myIframe").vspace = 8; |
|
Value | |
Integer of pixel count. |
|
Default | |
0 |
longDesc | NN 6 IE 5(Mac)/6(Win) DOM 1 |
Read/Write | |
Reflects the longDesc attribute of the iframe element. Version 6 browsers provide no significant functionality for this attribute or property. |
|
Value | |
URL string. |
|
Default | |
Empty string. |
marginHeight, marginWidth | NN 6 IE 4 DOM 1 |
Read/Write | |
Control the number of pixels between the inner edge of a frame and the content rendered inside the frame. An adjustment to either property sets the other property to zero, eliminating the default margin provided by the browser. Not reliable in IE 4 for Windows, but operable in all other supported versions. |
|
Value | |
Positive integer value or zero. |
|
Default | |
Varies with browser and operating system. |
name | NN 6 IE 4 DOM 1 |
Read/Write | |
This is the identifier associated with an iframe for use as the value assigned to target attributes or as script references to the frame. The value is usually assigned via the name attribute, but it can be modified by script if necessary. |
|
Value | |
Case-sensitive string identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character. |
|
Default | |
None. |
noResize | NN n/a IE 4 DOM n/a |
Read/Write | |
Specifies whether the frame can be resized by the user. Not applicable to an iframe element. |
scrolling | NN 6 IE 4 DOM 1 |
Read/Write | |
Specifies the treatment of scrollbars for an iframe when the content exceeds the visible area of the iframe. You can force an iframe to display scrollbars at all times or never. Or you can let the browser determine the need for scrolling. It is not uncommon for browsers to ignore scripted changes to this property. Make your choice in the element's scrolling attribute. |
|
Example | |
document.getElementById("myIframe").scrolling = "no"; |
|
Value | |
One of three constants (as a string): auto | no | yes. |
|
Default | |
auto |
src | NN 6 IE 4 DOM 1 |
Read/Write | |
Indicates the URL of the external content file loaded into the current element. To change the content, assign a new URL to the property. |
|
Example | |
document.getElementById("myIframe").src = "section2.html"; |
|
Value | |
Complete or relative URL as a string. |
|
Default | |
None. |
tabIndex | NN 6 IE 4 DOM 1 |
Read/Write | |
This is a number that indicates the sequence of this element within the tabbing order of all focusable elements in the document. Tabbing order follows a strict set of rules. Elements that have values other than zero assigned to their tabIndex properties are first in line when a user starts tabbing in a page. Focus starts with the element with the lowest tabIndex value and proceeds in order to the highest value, regardless of physical location on the page or in the document. If two elements have the same tabIndex values, the element that comes earlier in the document receives focus first. Next come all elements that either don't support the tabIndex property or have the value set to zero. These elements receive focus in the order in which they appear in the document. |
|
The W3C DOM and Netscape 6 limit the tabIndex property to the following element objects: a, area, button, input, object, select, textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, span, table, and td. IE 5 adds every other renderable element. A negative value in IE (only) removes an element from tabbing order entirely. |
|
Links and anchors cannot be tabbed to with the Mac version of IE 4, so the tabIndex property for a element objects is ignored in that version. |
|
Example | |
document.getElementById("link3").tabIndex = 6; |
|
Value | |
Integer. |
|
Default | |
0 |
vspace | |
See hspace. |
width | |
See height. |