Is the current window in a frame?
if (window.frameElement) {
let answer = "YES";
}
Try it Yourself »
More example below.
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.
A frame can be any embedding element:
<frame>, <iframe>, <embed>, <object>, etc.
window.frameElement
frameElement
Type | Description |
An object | The host of the window (the parent document). Or null if no host exists. |
If the window is in a frame, change the URL to "91xjr.com":
const frame = window.frameElement;
if (frame) {
frame.src = "https://www.91xjr.com/";
}
Try it Yourself »
window.frameElement
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!