HTMLIFrameElement

  • Revision slug: DOM/HTMLIFrameElement
  • Revision title: HTMLIFrameElement
  • Revision id: 398855
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

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")}}.

Name Type Description
align {{obsolete_inline}} {{domxref("DOMString")}} Specifies the alignment of the frame with respect to the surrounding context.
allowfullscreen {{experimental_inline}} {{domxref("Boolean")}} Indicates whether or not the inline frame is willing to be placed into full screen mode. See Using full-screen mode for details.
contentDocument {{readonlyInline}} {{domxref("Document")}} The active document in the inline frame's nested browsing context.
contentWindow {{readonlyInline}} {{domxref("WindowProxy")}} The window proxy for the nested browsing context.
frameborder {{obsolete_inline}} {{domxref("DOMString")}} Indicates whether to create borders between frames.
height {{domxref("DOMString")}} Reflects the {{htmlattrxref("height", "iframe")}} HTML attribute, indicating the height of the frame.
longDesc {{obsolete_inline}} {{domxref("DOMString")}} URI of a long description of the frame.
marginHeight {{obsolete_inline}} {{domxref("DOMString")}} Height of the frame margin.
marginWidth {{obsolete_inline}} {{domxref("DOMString")}} Width of the frame margin.
name {{domxref("DOMString")}} Reflects the {{htmlattrxref("name", "iframe")}} HTML attribute, containing a name by which to refer to the frame.
sandbox {{domxref("DOMSettableTokenList")}} Reflects the {{htmlattrxref("sandbox", "iframe")}} HTML attribute, indicating extra restrictions on the behavior of the nested content.
scrolling {{obsolete_inline}} {{domxref("DOMString")}} Indicates whether the browser should provide scrollbars for the frame.
seamless {{experimental_inline}} {{domxref("Boolean")}} Reflects the {{htmlattrxref("seamless", "iframe")}} HTML attribute, indicating that the inline frame should be rendered seamlessly within the parent document.
src {{domxref("DOMString")}} Reflects the {{htmlattrxref("src", "iframe")}} HTML attribute, containing the address of the content to be embedded.
srcdoc {{domxref("DOMString")}} The content to display in the frame.
width {{domxref("DOMString")}} 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 {{CompatNo}} {{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 {{CompatNo}} {{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] Gecko, and maybe other browsers as it is a late change in the specification, implements sandbox as a {{domxref("DOMString")}} instead of a {{domxref("DOMSettableTokenList")}} ({{bug(845067)}}).

See also

  • The HTML element implementing this interface: {{HTMLElement("iframe")}}

Revision Source

<div>
  {{DomRef}}</div>
<p>The <strong><code>HTMLIFrameElement</code></strong> 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.</p>
<h2 id="Properties">Properties</h2>
<p><em>Inherits properties from its parent, {{domxref("HTMLElement")}}</em>.</p>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Type</th>
      <th scope="col">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>align</code>&nbsp;{{obsolete_inline}}</td>
      <td>{{domxref("DOMString")}}</td>
      <td>Specifies the alignment of the frame with respect to the surrounding context.</td>
    </tr>
    <tr>
      <td><code>allowfullscreen</code>&nbsp;{{experimental_inline}}</td>
      <td>{{domxref("Boolean")}}</td>
      <td>Indicates whether or not the inline frame is willing to be placed into full screen mode. See <a href="/en-US/docs/DOM/Using_full-screen_mode" title="https://developer.mozilla.org/en/DOM/Using_full-screen_mode">Using full-screen mode</a> for details.</td>
    </tr>
    <tr>
      <td><code>contentDocument</code>&nbsp;{{readonlyInline}}</td>
      <td>{{domxref("Document")}}</td>
      <td>The active document in the inline frame's nested browsing context.</td>
    </tr>
    <tr>
      <td><code>contentWindow</code>&nbsp;{{readonlyInline}}</td>
      <td>{{domxref("WindowProxy")}}</td>
      <td>The window proxy for the nested browsing context.</td>
    </tr>
    <tr>
      <td><code>frameborder</code>&nbsp;{{obsolete_inline}}</td>
      <td>{{domxref("DOMString")}}</td>
      <td>Indicates whether to create borders between frames.</td>
    </tr>
    <tr>
      <td><code>height</code></td>
      <td>{{domxref("DOMString")}}</td>
      <td>Reflects the {{htmlattrxref("height", "iframe")}} HTML&nbsp;attribute, indicating the height of the frame.</td>
    </tr>
    <tr>
      <td><code>longDesc</code>&nbsp;{{obsolete_inline}}</td>
      <td>{{domxref("DOMString")}}</td>
      <td>URI of a long description of the frame.</td>
    </tr>
    <tr>
      <td><code>marginHeight</code>&nbsp;{{obsolete_inline}}</td>
      <td>{{domxref("DOMString")}}</td>
      <td>Height of the frame margin.</td>
    </tr>
    <tr>
      <td><code>marginWidth</code>&nbsp;{{obsolete_inline}}</td>
      <td>{{domxref("DOMString")}}</td>
      <td>Width of the frame margin.</td>
    </tr>
    <tr>
      <td><code>name</code></td>
      <td>{{domxref("DOMString")}}</td>
      <td>Reflects the {{htmlattrxref("name", "iframe")}} HTML&nbsp;attribute, containing a name by which to refer to the frame.</td>
    </tr>
    <tr>
      <td><code>sandbox</code></td>
      <td>{{domxref("DOMSettableTokenList")}}</td>
      <td>Reflects the {{htmlattrxref("sandbox", "iframe")}} HTML&nbsp;attribute, indicating extra restrictions on the behavior of the nested content.</td>
    </tr>
    <tr>
      <td><code>scrolling</code>&nbsp;{{obsolete_inline}}</td>
      <td>{{domxref("DOMString")}}</td>
      <td>Indicates whether the browser should provide scrollbars for the frame.</td>
    </tr>
    <tr>
      <td><code>seamless</code>&nbsp;{{experimental_inline}}</td>
      <td>{{domxref("Boolean")}}</td>
      <td>Reflects the {{htmlattrxref("seamless", "iframe")}} HTML&nbsp;attribute, indicating that the inline frame should be rendered seamlessly within the parent document.</td>
    </tr>
    <tr>
      <td><code>src</code></td>
      <td>{{domxref("DOMString")}}</td>
      <td>Reflects the {{htmlattrxref("src", "iframe")}} HTML&nbsp;attribute, containing the address of the content to be embedded.</td>
    </tr>
    <tr>
      <td><code>srcdoc</code></td>
      <td>{{domxref("DOMString")}}</td>
      <td>The content to display in the frame.</td>
    </tr>
    <tr>
      <td><code>width</code></td>
      <td>{{domxref("DOMString")}}</td>
      <td>Reflects the {{htmlattrxref("width", "iframe")}}&nbsp;HTML&nbsp;attribute, indicating the width of the frame.</td>
    </tr>
  </tbody>
</table>
<h2 id="Methods">Methods</h2>
<p><em>No specific method; inherits properties from its parent, {{domxref("HTMLElement")}}</em>.</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
    <tr>
      <td>{{SpecName('HTML WHATWG', "the-iframe-element.html#the-iframe-element", "HTMLIFrameElement")}}</td>
      <td>{{Spec2('HTML WHATWG')}}</td>
      <td>The following property has been added: <code>allowFullscreen</code>.</td>
    </tr>
    <tr>
      <td>{{SpecName('HTML5 W3C', "embedded-content-0.html#the-iframe-element", "HTMLIFrameElement")}}</td>
      <td>{{Spec2('HTML5 W3C')}}</td>
      <td>The following properties are now obsolete: <code>scrolling</code>, <code>marginWidth</code>, <code>marginHeight</code>, <code>longDesc</code>, <code>frameBorder</code>, and <code>align</code>.<br />
        The following properties have been added: <code>srcdoc</code>, <code>sandbox</code>, <code>seamless</code>, and <code>contentWindow</code>.</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM2 HTML', 'html.html#ID-50708718', 'HTMLIFrameElement')}}</td>
      <td>{{Spec2('DOM2 HTML')}}</td>
      <td>The <code>contentDocument</code> property has been added.</td>
    </tr>
    <tr>
      <td>{{SpecName('DOM1', 'level-one-html.html#ID-50708718', 'HTMLIFrameElement')}}</td>
      <td>{{Spec2('DOM1')}}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
  {{CompatibilityTable}}</div>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatGeckoDesktop(1.0)}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td><code>srcDoc</code></td>
        <td>4</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>sandbox</code></td>
        <td>4</td>
        <td>{{CompatGeckoDesktop(17)}} [1]</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>seamless</code> {{experimental_inline}}</td>
        <td>4</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>contentDocument</code></td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>8.0 (for older version use <code>HTMLIFrameElement.contentWindow.document</code> instead)</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td><code>contentWindow</code></td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>allowFullScreen</code> {{experimental_inline}}</td>
        <td>17 {{property_prefix("-webkit")}}<br />
          <em>Daily test builds only</em></td>
        <td>{{compatGeckoDesktop(9.0)}} {{property_prefix("-moz")}}<br />
          {{compatGeckoDesktop(18.0)}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatGeckoMobile(1.0)}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td><code>srcDoc</code></td>
        <td>4</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>sandbox</code></td>
        <td>4</td>
        <td>{{CompatGeckoMobile(17)}} [1]</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>seamless</code> {{experimental_inline}}</td>
        <td>4</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>contentDocument</code></td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
        <td>{{CompatVersionUnknown}}</td>
      </tr>
      <tr>
        <td><code>contentWindow</code></td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td><code>allowFullScreen</code> {{experimental_inline}}</td>
        <td>17 {{property_prefix("-webkit")}}<br />
          <em>Daily test builds only</em></td>
        <td>{{compatGeckoMobile(9.0)}} {{property_prefix("-moz")}}<br />
          {{compatGeckoMobile(18.0)}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<p>[1] Gecko, and maybe other browsers as it is a late change in the specification, implements <code>sandbox</code> as a {{domxref("DOMString")}} instead of a {{domxref("DOMSettableTokenList")}} ({{bug(845067)}}).</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>The HTML element implementing this interface: {{HTMLElement("iframe")}}</li>
</ul>
Revert to this revision