Summary
Returns the element (such as <iframe>
or <object>
) in which the window is embedded, or null
if the window is top-level.
Syntax
frameEl = window.frameElement;
frameEl
is the element which the window is embedded into, ornull
if the window is top-level.
Example
var frameEl = window.frameElement; // If we are inside a frame, then change its 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.
Specification
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 4? | 1.0 (1.7 or earlier) | 5.5? | 12.1? | 4? |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 1.0 (1.7 or earlier) | ? | ? | ? |
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 theframeElement
of the child window.
Document Tags and Contributors
Tags:
Contributors to this page:
Terry,
fscholz,
duncansmart,
teoli,
cpigat,
MHasan,
kscarfone,
leifwickland,
ethertank,
Sheppy,
GijsKruitbosch,
thaddee.tyl@gmail.com,
Potappo,
Lenatis,
Mgjbot,
Nickolay,
Mw22
Last updated by:
Terry,