Window frameElement
Example
Is the current window in a frame?
if (window.frameElement) {
  let answer = "YES";
}
Try it Yourself »
More example below.
Definition and Usage
The frameElement property returns the frame where the window runs.
The frameElement property returns null if the 
window does not run in a frame.
The frameElement property is read only.
Note
A frame can be any embedding element:
<frame>, <iframe>, <embed>, <object>, etc.
See Also:
Syntax
window.frameElement
or:
frameElement
Return Value
| Type | Description | 
| An object | The host of the window (the parent document). Or nullif no host exists. | 
More Examples
Example
If the window is in a frame, change the URL to "w3schools.com":
const frame = window.frameElement;
if (frame) {
    frame.src = "https://www.w3schools.com/";
}
Try it Yourself »
Browser Support
window.frameElement is supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE | 
| Yes | Yes | Yes | Yes | Yes | Yes | 
 
 
