aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/content/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/content/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/content/index.html')
-rw-r--r--files/zh-cn/web/api/window/content/index.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/window/content/index.html b/files/zh-cn/web/api/window/content/index.html
new file mode 100644
index 0000000000..d3d3f4be3d
--- /dev/null
+++ b/files/zh-cn/web/api/window/content/index.html
@@ -0,0 +1,27 @@
+---
+title: window.content
+slug: Web/API/Window/content
+translation_of: Web/API/Window/content
+---
+<p>{{ ApiRef() }}</p>
+<h3 id="Summary" name="Summary">概述</h3>
+<p>返回主内容窗口的<a href="zh-CN/DOM/window">Window对象</a>.该属性只在包含有属性<code>type="content-primary"</code>的<code>&lt;browser&gt;</code> (或者 <code>tabbrowser</code> 或者 <code>&lt;iframe&gt;</code>)标签的XUL窗口下才会用到.最常用到的地方就是Firefox的主窗口, <code>browser.xul</code>. 在这种情况下, <code>content</code> 返回一个浏览器中的当前页面的<code>Window对象的引用</code>.相当于<code><var>browserRef</var>.contentWindow的快捷方式</code>.</p>
+<p>在一个非特权的内容窗口中 (网页), <code>content</code> 等同于普通的 <a href="zh-CN/DOM/window.top">top</a> (除非网页是在侧边栏中加载的, <code>content</code>仍然会指向当前标签页中的<code>Window对象</code>).</p>
+<p>一些旧的代码示例中使用了 <code>_content</code> 而不是 <code>content</code>.该形式的属性名已经被废弃很久了,你应该在新的代码中使用<code>content</code>.</p>
+<h3 id="Syntax" name="Syntax">语法</h3>
+<pre class="eval">var <var>windowObject</var> = window.content;
+</pre>
+<h3 id="Example" name="Example">例子</h3>
+<p>在一个拥有<code>&lt;browser type="content-primary"/&gt;标签的</code>chrome XUL 窗口下运行下面的代码.会在浏览器当前显示的页面上的第一个div标签上添加一个红色的边框:</p>
+<pre class="eval">content.document.getElementsByTagName("div")[0].style.border = "solid red 1px";
+</pre>
+<h3 id="Specification" name="Specification">规范</h3>
+<p>不属于W3C规范.</p>
+<h3 id="See_also" name="See_also">相关链接</h3>
+<ul>
+ <li><a href="zh-CN/Working_with_windows_in_chrome_code">Working with windows in chrome code</a></li>
+ <li>When accessing content documents from privileged code, be aware of <a href="zh-CN/XPCNativeWrapper">XPCNativeWrappers</a>.</li>
+</ul>
+<div class="noinclude">
+  </div>
+<p>{{ languages( { "fr": "fr/DOM/window.content", "ja": "ja/DOM/window.content", "pl": "pl/DOM/window.content" } ) }}</p>