HTML DOM IFrame Object

IFrame object

The IFrame object represents the HTML <iframe> element.

Access the IFrame object

You can use getElementById() to access the <iframe> element:

var x = document.getElementById("myFrame");

Try It Yourself

Tip:You can also use window.frames property Accessing the <iframe> element.

Creating IFrame Object

You can use the document.createElement() method to create an <iframe> element:

var x = document.createElement("IFRAME");

Try It Yourself

IFrame Object Properties

Attributes Description
align Not supported in HTML5.Please use style.cssFloat.
contentDocument Returns the document object generated by the iframe.
contentWindow Returns the window object generated by the iframe.
frameBorder

Not supported in HTML5.Please use style.border.

Sets or returns the value of the frameborder attribute in the iframe.

height Sets or returns the value of the height attribute in the iframe.
longDesc

Not supported in HTML5.

Sets or returns the value of the longdesc attribute in the iframe.

marginHeight

Not supported in HTML5.Please use style.margin.

Sets or returns the value of the marginheight attribute in the iframe.

marginWidth

Not supported in HTML5.Please use style.margin.

Sets or returns the value of the marginwidth attribute in the iframe.

name Sets or returns the value of the name attribute in the iframe.
sandbox Sets or returns the value of the sandbox attribute in the iframe.
scrolling

Not supported in HTML5.

Sets or returns the value of the scrolling attribute in the iframe.

seamless Sets or returns whether the iframe should look like part of a document (borderless or with scrollbars).
src Sets or returns the value of the src attribute in the iframe.
srcdoc Sets or returns the value of the srcdoc attribute in the iframe.
width Sets or returns the value of the width attribute in the iframe.

Standard properties and events

The IFrame object supports standardsAttributesandEvents.

Related Pages

HTML Reference Manual:HTML <iframe> Tag