Returns the element (such as <iframe>
or <object>
) in which the window is embedded, or null
if the element is either top-level or is embedded into a document with a different script origin; that is, in cross-origin situations.
frameEl = window.frameElement;
frameEl
is the element which the window is embedded into. If the window isn't embedded into another document, or if the document into which it's embedded has a different origin (such as having been located from a different domain), this is null
.Despite this property's name, it works for documents embedded within any embedding point, including <object>
, <iframe>
, or <embed>
.
var frameEl = window.frameElement; // If we're embedded, change the containing element's URL to 'http://mozilla.org/' if (frameEl) { frameEl.src = 'http://mozilla.org/'; }
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'Window.frameElement' in that specification. | Candidate Recommendation | Initial specification. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | ? | Yes | Yes | ? | ? | ? |
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.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/window/frameElement