Window.frameElement - Web APIs 编辑
The Window.frameElement
property returns the element (such as <iframe>
or <object>
) in which the window is embedded.
Note: Despite this property's name, it works for documents embedded within any embedding point, including <object>
, <iframe>
, or <embed>
.
Syntax
const frameEl = window.frameElement
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, the value is null
instead.
Example
const frameEl = window.frameElement;
// If we're embedded, change the containing element's URL to 'http://mozilla.org/'
if (frameEl) {
frameEl.src = 'http://mozilla.org/';
}
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'Window.frameElement' in that specification. | Candidate Recommendation | Initial specification. |
Browser compatibility
BCD tables only load in the browser
See also
window.frames
returns an array-like object, listing the direct sub-frames of the current window.window.parent
returns the parent window, which is the window containing theframeElement
of the child window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论