Summary

Returns the element (such as <iframe> or <object>) in which the window is embedded, or null if the window is top-level.

Syntax

frameEl = window.frameElement;
  • frameEl is the element which the window is embedded into, or null if the window is top-level.

Example

var frameEl = window.frameElement;
// If we are inside a frame, then change its URL to 'http://mozilla.org/'
if (frameEl) {
  frameEl.src = 'http://mozilla.org/';
}

Notes

Note that despite its name, the property also works for documents inside <object> and other embedding points.

Specification

WHATWG

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 4? 1.0 (1.7 or earlier) 5.5? 12.1? 4?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 1.0 (1.7 or earlier) ? ? ?

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.
Hide Sidebar