Window frameElement property
- Previous Page focus()
- Next Page frames
- Go to the Previous Level Window Object
Definition and usage
frameElement
The property returns the frame in which the window is running.
If the window is not running in a frame, then frameElement
The property returns null
.
frameElement
The property is read-only.
Tip:A frame can be any embedded element:<frame>, <iframe>, <embed>, <object> et al.
See also:
Instance
Example 1
Is the current window in a frame?
if (window.frameElement) { let answer = "YES"; }
Example 2
If the window is in a frame, change the URL to "codew3c.com":
const frame = window.frameElement; if (frame) { frame.src = "https://www.codew3c.com/"; }
Syntax
window.frameElement
Or:
frameElement
Return value
Type | Description |
---|---|
Object. |
The host of the window (parent document). If 'host' does not exist, it is null. |
Browser support
All browsers support window.frameElement
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page focus()
- Next Page frames
- Go to the Previous Level Window Object