Window: frameElement property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
TheWindow.frameElement propertyreturns the element (such as<iframe> or<object>)in which the window is embedded.
In this article
Value
The element which the window is embedded into. If the window isn't embedded intoanother document, or if the document into which it's embedded has a differentorigin, the value isnull instead.
Examples
js
const frameEl = window.frameElement;// If we're embedded, change the containing element's URL to 'https://mozilla.org/'if (frameEl) { frameEl.src = "https://mozilla.org/";}Specifications
| Specification |
|---|
| HTML> # dom-frameelement-dev> |
Browser compatibility
See also
window.framesreturns an array-like object, listing the directsub-frames of the current window.window.parentreturns the parent window, which is the windowcontaining theframeElementof the child window.