blob: d2142ec21e891caabd7ad78a6740150849e10445 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
---
title: Window.top
slug: Web/API/Window/top
tags:
- API
- HTML DOM
- Property
- Reference
- Window
translation_of: Web/API/Window/top
---
<p>{{APIRef}}</p>
<p>返回窗口层级最顶层窗口的引用。</p>
<h2 id="语法" name="语法">语法</h2>
<pre class="eval">var <em>topWindow</em> = window.top;
</pre>
<h2 id="备注" name="备注"><span style="font-family: Arial,Arial,Helvetica,sans-serif; line-height: 20px;">备注</span></h2>
<p> <code style="font-style: normal; line-height: 1.5;"><a href="https://developer.mozilla.org/zh-CN/DOM/window.parent" title="en/DOM/window.parent">window.parent</a></code> <span style="line-height: 1.5;">返回当前窗口的直接父对象,而 </span>{{domxref("window.top")}}<span style="line-height: 1.5;"> </span><span style="font-family: 'Courier New','Andale Mono',monospace; line-height: inherit;">返回最顶层的窗口对象。</span></p>
<p> </p>
<p>当你在处理父窗口的子框架(subframe),而你想获取顶层框架时,这个属性相当有用。</p>
<h2 id="规范" name="规范" style="line-height: 24px;">规范</h2>
<table>
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', 'browsers.html#dom-top', 'window.top')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', 'browsers.html#dom-top', 'window.top')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性" name="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.Window.top")}}</p>
|