aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/frameelement/index.html
blob: 12c587d7258e63efb25a7ffca68646a5adaa920b (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: window.frameElement
slug: Web/API/Window/frameElement
translation_of: Web/API/Window/frameElement
---
<p>{{ ApiRef() }}</p>
<h3 id="Summary" name="Summary">概述</h3>
<p>返回嵌入当前<code>window</code>对象的元素(比如 <code>&lt;iframe&gt;</code> 或者 <code>&lt;object&gt;</code>),如果当前<code>window</code>对象已经是顶层窗口,则返回<code>null</code>.</p>
<h3 id="Syntax" name="Syntax">语法</h3>
<pre class="eval">var <em>frameEl</em> = window.frameElement;
</pre>
<h3 id="Example" name="Example">例子</h3>
<pre class="eval">var frameEl = window.frameElement;
// 如果当前窗口被包含在一个框架里面,则将该框架的地址跳到'<span class="nowiki">http://mozilla.org/</span>'
if (frameEl)
  frameEl.src = '<span class="nowiki">http://mozilla.org/</span>';
</pre>
<h3 id="Notes" name="Notes">备注</h3>
<p>虽然该属性名为<code>frameElement</code>,但该属性也会返回其他类型比如 <code>&lt;object&gt;</code> 或者其他可嵌入窗口的元素.</p>
<h3 id="See_also" name="See_also">相关链接</h3>
<ul>
 <li><code><a href="/zh-cn/DOM/window.frames" title="zh-cn/DOM/window.frames">window.frames</a></code> 返回一个类数组对象,返回当前窗口的所有子框架元素.</li>
 <li><code><a href="/zh-cn/DOM/window.parent" title="zh-cn/DOM/window.parent">window.parent</a></code> 返回当前窗口的父窗口,也就是说,包含当前窗口所在的<code>frameElement</code>元素的窗口.</li>
</ul>
<h3 id="Specification" name="Specification">规范</h3>
<p><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/#dom-frameelement" title="http://www.whatwg.org/specs/web-apps/current-work/#dom-frameelement">WHATWG</a></p>
<h3 id="浏览器兼容性">浏览器兼容性</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>18</td>
    <td>{{ CompatGeckoDesktop("1") }}</td>
    <td>5.5?</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatGeckoDesktop("1") }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<p>{{ languages( { "ja": "ja/DOM/window.frameElement", "pl": "pl/DOM/window.frameElement", "en": "en/DOM/window.frameElement" } ) }}</p>