Visit Mozilla.org

DOM:window.frameElement

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

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

[edit] Syntax

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

[edit] Example

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

[edit] Notes

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

[edit] 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.

[edit] Specification

DOM Level 0. Not part of any standard.