返回窗口层级最顶层窗口的引用。

语法

var topWindow = window.top;

备注

 window.parent 返回当前窗口的直接父对象,而 window.top 返回最顶层的窗口对象。

 

当你在处理父窗口的子框架(subframe),而你想获取顶层框架时,这个属性相当有用。

规范

Specification Status Comment
HTML Living Standard
window.top
Living Standard  
HTML5
window.top
Recommendation Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
topChrome Full support YesEdge Full support 12Firefox Full support Yes
Notes
Full support Yes
Notes
Notes Starting in Firefox 6, this property is read only, as defined by the standard.
IE Full support YesOpera Full support YesSafari Full support YesWebView Android ? Chrome Android ? Edge Mobile Full support YesFirefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

文档标签和贡献者

此页面的贡献者: mdnwebdocs-bot, fordream001, teoli, AlexChao, Josephok
最后编辑者: mdnwebdocs-bot,