The Window.frameElement
property returns the element (such as <iframe>
or <object>
) in which the window is embedded.
Note: Despite this property's name, it works for documents embedded within any embedding point, including <object>
, <iframe>
, or <embed>
.
Syntax
const frameEl = window.frameElement
Value
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, the value is null
instead.
Example
const frameEl = window.frameElement; // If we're embedded, change the containing element's URL to 'http://mozilla.org/' if (frameEl) { frameEl.src = 'http://mozilla.org/'; }
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living StandardThe definition of 'Window.frameElement' in that specification. | Candidate Recommendation | Initial specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
frameElement
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 5.5 |
Opera
Full support ≤12.1 |
Safari
Full support 3 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support ≤12.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
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.
Window.frameElement by Mozilla Contributors is licensed under CC-BY-SA 2.5.