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⁩.

The Window.frameElement property returns the element (such as <object>) in which the window is embedded.

Note: Despite this property's name, it works for documents embedded within any embedding point, including <object>, <embed>.

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 null 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.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.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant