-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
48 lines (35 loc) · 1.34 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: "Window: frameElement property"
short-title: frameElement
slug: Web/API/Window/frameElement
page-type: web-api-instance-property
browser-compat: api.Window.frameElement
---
{{ApiRef}}
The **`Window.frameElement`** property
returns the element (such as {{HTMLElement("iframe")}} or {{HTMLElement("object")}})
in which the window is embedded.
> **Note:** Despite this property's name, it works for documents embedded
> within any embedding point, including {{HTMLElement("object")}},
> {{HTMLElement("iframe")}}, or {{HTMLElement("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
{{glossary("origin")}}, the value is [`null`](/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
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("window.frames")}} returns an array-like object, listing the direct
sub-frames of the current window.
- {{domxref("window.parent")}} returns the parent window, which is the window
containing the `frameElement` of the child window.