The Window.frameElement
property returns the element (such as <iframe>
or <object>
) in which the window is embedded.
The Window.frameElement
property returns the element (such as <iframe>
or <object>
) in which the window is embedded.
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.
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/"; }
Specification |
---|
HTML Standard # dom-frameelement-dev |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
frameElement |
1 | 12 | 1 | 5.5 | ≤12.1 | 3 | 4.4 | 18 | 4 | ≤12.1 | 1 | 1.0 |
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–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/frameElement