# Window: frameElement property



The **`Window.frameElement`** property
returns the element (such as [iframe](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) or [object](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object))
in which the window is embedded.

> **NOTE:**
> Despite this property's name, it works for documents embedded
> within any embedding point, including [object](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object),
> [iframe](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe), or [embed](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/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
[origin](https://developer.mozilla.org/en-US/docs/Glossary/origin), the value is [`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/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

## Browser compatibility

## See also

- [window.frames](https://developer.mozilla.org/en-US/docs/Web/API/window/frames) returns an array-like object, listing the direct
  sub-frames of the current window.
- [window.parent](https://developer.mozilla.org/en-US/docs/Web/API/window/parent) returns the parent window, which is the window
  containing the `frameElement` of the child window.
