--- title: HTMLIFrameElement slug: Web/API/HTMLIFrameElement tags: - API translation_of: Web/API/HTMLIFrameElement ---
{{APIRef("HTML DOM")}}

The HTMLIFrameElement interface provides special properties and methods (beyond those of the {{domxref("HTMLElement")}} interface it also has available to it by inheritance) for manipulating the layout and presentation of inline frame elements.

Properties

Inherits properties from its parent, {{domxref("HTMLElement")}}.

{{domxref("HTMLIFrameElement.align")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} that specifies the alignment of the frame with respect to the surrounding context.
{{domxref("HTMLIFrameElement.allowfullscreen")}} {{experimental_inline}}
Is a {{domxref("Boolean")}} that indicates whether or not the inline frame is willing to be placed into full screen mode. See Using full-screen mode for details.
{{domxref("HTMLIFrameElement.contentDocument")}} {{readonlyInline}}
Returns a {{domxref("Document")}}, the active document in the inline frame's nested browsing context.
{{domxref("HTMLIFrameElement.contentWindow")}} {{readonlyInline}}
Returns a {{domxref("WindowProxy")}}, the window proxy for the nested browsing context.
{{domxref("HTMLIFrameElement.frameborder")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} that indicates whether to create borders between frames.
{{domxref("HTMLIFrameElement.height")}}
Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("height", "iframe")}} HTML attribute, indicating the height of the frame.
{{domxref("HTMLIFrameElement.longDesc")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} that contains the URI of a long description of the frame.
{{domxref("HTMLIFrameElement.marginHeight")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} being the height of the frame margin.
{{domxref("HTMLIFrameElement.marginWidth")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} being the width of the frame margin.
{{domxref("HTMLIFrameElement.name")}}
Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("name", "iframe")}} HTML attribute, containing a name by which to refer to the frame.
{{domxref("HTMLIFrameElement.sandbox")}}
Is a {{domxref("DOMSettableTokenList")}} that reflects the {{htmlattrxref("sandbox", "iframe")}} HTML attribute, indicating extra restrictions on the behavior of the nested content.
{{domxref("HTMLIFrameElement.scrolling")}} {{obsolete_inline}}
Is a {{domxref("DOMString")}} that indicates whether the browser should provide scrollbars for the frame.
{{domxref("HTMLIFrameElement.seamless")}} {{experimental_inline}}
Is a {{domxref("Boolean")}} that reflects the {{htmlattrxref("seamless", "iframe")}} HTML attribute, indicating that the inline frame should be rendered seamlessly within the parent document.
{{domxref("HTMLIFrameElement.src")}}
Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("src", "iframe")}} HTML attribute, containing the address of the content to be embedded.
{{domxref("HTMLIFrameElement.srcdoc")}}
Is a {{domxref("DOMString")}} that represents the content to display in the frame.
{{domxref("HTMLIFrameElement.width")}}
Is a {{domxref("DOMString")}} that reflects the {{htmlattrxref("width", "iframe")}} HTML attribute, indicating the width of the frame.

Methods

No specific method; inherits properties from its parent, {{domxref("HTMLElement")}}.

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', "the-iframe-element.html#the-iframe-element", "HTMLIFrameElement")}} {{Spec2('HTML WHATWG')}} The following property has been added: allowFullscreen.
{{SpecName('HTML5 W3C', "embedded-content-0.html#the-iframe-element", "HTMLIFrameElement")}} {{Spec2('HTML5 W3C')}} The following properties are now obsolete: scrolling, marginWidth, marginHeight, longDesc, frameBorder, and align.
The following properties have been added: srcdoc, sandbox, seamless, and contentWindow.
{{SpecName('DOM2 HTML', 'html.html#ID-50708718', 'HTMLIFrameElement')}} {{Spec2('DOM2 HTML')}} The contentDocument property has been added.
{{SpecName('DOM1', 'level-one-html.html#ID-50708718', 'HTMLIFrameElement')}} {{Spec2('DOM1')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatVersionUnknown}} {{CompatGeckoDesktop(1.0)}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
srcdoc 4 {{CompatGeckoDesktop(25)}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
sandbox 4 {{CompatGeckoDesktop(17)}} [1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
seamless {{experimental_inline}} 4 {{CompatNo}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
contentDocument {{CompatVersionUnknown}} {{CompatVersionUnknown}} 8.0 (for older version use HTMLIFrameElement.contentWindow.document instead) {{CompatVersionUnknown}} {{CompatVersionUnknown}}
contentWindow {{CompatUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}}
allowFullScreen {{experimental_inline}} 17 {{property_prefix("-webkit")}}
Daily test builds only
{{compatGeckoDesktop(9.0)}} {{property_prefix("-moz")}}
{{compatGeckoDesktop(18.0)}}
{{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatGeckoMobile(1.0)}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
srcdoc 4 {{CompatGeckoMobile(25)}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
sandbox 4 {{CompatGeckoMobile(17)}} [1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
seamless {{experimental_inline}} 4 {{CompatNo}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
contentDocument {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
contentWindow {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
allowFullScreen {{experimental_inline}} 17 {{property_prefix("-webkit")}}
Daily test builds only
{{compatGeckoMobile(9.0)}} {{property_prefix("-moz")}}
{{compatGeckoMobile(18.0)}}
{{CompatNo}} {{CompatNo}} {{CompatNo}}

[1] Previously, the type of sandbox was a {{domxref("DOMString")}} instead of a {{domxref("DOMSettableTokenList")}}. This has been fixed with Gecko 29.0 {{geckoRelease(29)}}) ({{bug(845067)}}). Other browsers may still implement the property as DOMString since it was a late change in the specification.

Firefox OS notes

Firefox OS extend the HTMLIFrameElement interface to support browser iframes. Those extra methods are made for privileged applications which want to implement a browser like application for Firefox OS devices. Not that in that context, the HTMLIFrameElement also inherit methods from the {{domxref("EventTarget")}} interface. To learn how to implement such applications, see the Using the Browser API article.

{{domxref("HTMLIFrameElement.setVisible()","HTMLIFrameElement.setVisible(visible)")}}
Allows the parent to explicitly change the visibility state of the browser iframes.
{{domxref("HTMLIFrameElement.getVisible()","HTMLIFrameElement.getVisible()")}}
Returns the current visibility state of the browser iframe. Returns a {{domxref("DOMRequest")}}.
{{domxref("HTMLIFrameElement.sendMouseEvent()","HTMLIFrameElement.sendMouseEvent(type, x, y, button, clickCount, modifiers)")}}
Send a mouse event to the browser iframe.
{{domxref("HTMLIFrameElement.sendTouchEvent()","HTMLIFrameElement.sendTouchEvent(type, identifiers, touchesX, touchesY,radiisX, radiisY, rotationAngles, forces,count, modifiers)")}}
Send a touch event to the browser iframe.
{{domxref("HTMLIFrameElement.goBack()","HTMLIFrameElement.goBack()")}}
Navigate the browser iframe back.
{{domxref("HTMLIFrameElement.goForward()","HTMLIFrameElement.goForward()")}}
Navigate the browser iframe forward.
{{domxref("HTMLIFrameElement.reload()","HTMLIFrameElement.reload()")}}
Reload the browser iframe.
{{domxref("HTMLIFrameElement.stop()","HTMLIFrameElement.stop()")}}
Stop loading the browser iframe content.
{{domxref("HTMLIFrameElement.purgeHistory()","HTMLIFrameElement.purgeHistory()")}}
Allows to remove the all browsing history of the browser iframe.
{{domxref("HTMLIFrameElement.getScreenshot()","HTMLIFrameElement.getScreenshot(maxWidth, maxHeight)")}}
Allows to take a screenshot of the browser iframe's content, scaled to fit within maxWidth and maxHeight pixels. Returns a {{domxref("DOMRequest")}}.
{{domxref("HTMLIFrameElement.addNextPaintListener()","HTMLIFrameElement.addNextPaintListener()")}}
Add a listener to recieve an event the first time the browser iframe is ready to paint (This listener is sent an event after the first {{event("MozAfterPaint")}} event is dispacted in the iframe.)
{{domxref("HTMLIFrameElement.removeNextPaintListener()","HTMLIFrameElement.removeNextPaintListener()")}}
Remove the listener added by the previous function.
{{domxref("HTMLIFrameElement.getCanGoBack()","HTMLIFrameElement.getCanGoBack()")}}
Returns a {{domxref("DOMRequest")}} which result is a boolean indicating wether the browser iframe can be navigate backward.
{{domxref("HTMLIFrameElement.getCanGoForward()","HTMLIFrameElement.getCanGoForward()")}}
Returns a {{domxref("DOMRequest")}} which result is a boolean indicating wether the browser iframe can be navigate forward.

See also