Window.frameElement

  • Revision slug: DOM/window.frameElement
  • Revision title: window.frameElement
  • Revision id: 232749
  • Created:
  • Creator: thaddee.tyl@gmail.com
  • Is current revision? No
  • Comment Compatibility of Google Chrome; 1 words added, 4 words removed

Revision Content

{{ DomRef() }}

Summary

Returns the element (such as <iframe> or <object>) in which the window is embedded, or null if the window is top-level.

Syntax

var frameEl = window.frameElement;
  • frameEl is the element which the window is embedded into, or null if the window is top-level.

Example

var frameEl = window.frameElement;
// if we are inside a frame, then change it's URL to 'http://mozilla.org/'
if (frameEl)
  frameEl.src = 'http://mozilla.org/';

Notes

Note that despite its name, the property also works for documents inside <object> and other embedding points.

See also

  • window.frames returns an array-like object, listing the direct sub-frames of the current window.
  • window.parent returns the parent window, which is the window containing the frameElement of the child window.

Specification

{{ DOM0() }}

 

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 18 {{ CompatGeckoDesktop("1") }} 5.5? {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatGeckoDesktop("1") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

{{ languages( { "ja": "ja/DOM/window.frameElement", "pl": "pl/DOM/window.frameElement" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 name="Summary">Summary</h3>
<p>Returns the element (such as <code>&lt;iframe&gt;</code> or <code>&lt;object&gt;</code>) in which the window is embedded, or <code>null</code> if the window is top-level.</p>
<h3 name="Syntax">Syntax</h3>
<pre class="eval">var <em>frameEl</em> = window.frameElement;
</pre>
<ul> <li><code>frameEl</code> is the element which the window is embedded into, or <code>null</code> if the window is top-level.</li>
</ul>
<h3 name="Example">Example</h3>
<pre class="eval">var frameEl = window.frameElement;
// if we are inside a frame, then change it's URL to '<span class="nowiki">http://mozilla.org/</span>'
if (frameEl)
  frameEl.src = '<span class="nowiki">http://mozilla.org/</span>';
</pre>
<h3 name="Notes">Notes</h3>
<p>Note that despite its name, the property also works for documents inside <code>&lt;object&gt;</code> and other embedding points.</p>
<h3 name="See_also">See also</h3>
<ul> <li><code><a href="/en/DOM/window.frames" title="en/DOM/window.frames">window.frames</a></code> returns an array-like object, listing the direct sub-frames of the current window.</li> <li><code><a href="/en/DOM/window.parent" title="en/DOM/window.parent">window.parent</a></code> returns the parent window, which is the window containing the <code>frameElement</code> of the child window.</li>
</ul>
<h3 name="Specification">Specification</h3>
<p>{{ DOM0() }}</p>
<p> </p>
<h3>Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<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</th> </tr> <tr> <td>Basic support</td> <td>18</td> <td>{{ CompatGeckoDesktop("1") }}</td> <td>5.5?</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</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 Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatGeckoDesktop("1") }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<p>{{ languages( { "ja": "ja/DOM/window.frameElement", "pl": "pl/DOM/window.frameElement" } ) }}</p>
Revert to this revision