blob: 2d3331b09671928ea24306718403303baae8d7d5 (
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
|
---
title: Window.frames
slug: Web/API/Window/frames
translation_of: Web/API/Window/frames
---
<p>{{ApiRef("Window")}}</p>
<h2 id="Summary" name="Summary">概要</h2>
<p>返回当前窗口,一个类数组对象,列出了当前窗口的所有直接子窗口。</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="eval"><em>frameList</em> = window.frames;
</pre>
<ul>
<li>frameList是一个frame对象的集合,它类似一个数组,有length属性且可以使用索引([i])来访问。</li>
<li><code>frameList === window</code> 计算结果为true。</li>
<li>在window.frames类数组中的每一项都代表了窗口对应给定对象的<frame>或<iframe>的内容,而不是(i)frame DOM元素(即window.frames[ 0 ]与document.getElementsByTagName( "iframe" )[ 0 ].contentWindow是相同的)。</li>
<li>有关返回值的更多详细信息,请参考 <a class="external" href="http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/5628c6f346859d4f/169aa7004565066?hl=en&ie=UTF-8&oe=utf-8&q=window.frames&pli=1" title="http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/5628c6f346859d4f/169aa7004565066?hl=en&ie=UTF-8&oe=utf-8&q=window.frames&pli=1">thread on mozilla.dev.platform</a> 。</li>
</ul>
<h2 id="Example" name="Example">实例</h2>
<pre class="brush: js">var frames = window.frames; // 或 // var frames = window.parent.frames;
for (var i = 0; i < frames.length; i++) {
// 在这对frames的一个frame做点什么
frames[i].document.body.style.background = "red";
}
</pre>
<h2 id="Specification" name="Specification">规范</h2>
<p>{{ DOM0() }}</p>
<table class="spectable standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG','browsers.html#dom-frames','Window.frames')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td> </td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', 'browsers.html#dom-frames', 'Window.frames')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td> </td>
</tr>
</tbody>
</table>
|