We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

 

返回窗口体系中的最顶层窗口的引用。

语法

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

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes)[1] (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ?

 [1] 从 Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3) 开始,该属性被修正为 只读(read only)

文档标签和贡献者

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