window.parent
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
概述
返回当前窗口的父窗口对象。
如果一个窗口没有父窗口,则它的 parent
属性为自身的引用。
如果当前窗口是一个 <iframe>
, <object>
, 或者 <frame>
,则它的父窗口是嵌入它的那个窗口
语法
var parentWindow = window.parent;
例子
if (window.parent != window.top) { // 至少有三层窗口 }
规范
Specification |
---|
HTML # dom-parent-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
parent |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
window.frameElement
返回嵌入当前窗口的 frame 对象。window.top
返回当前窗口最顶层的父窗口。