From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/window/content/index.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 files/zh-cn/web/api/window/content/index.html (limited to 'files/zh-cn/web/api/window/content/index.html') 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 +--- +

{{ ApiRef() }}

+

概述

+

返回主内容窗口的Window对象.该属性只在包含有属性type="content-primary"<browser> (或者 tabbrowser 或者 <iframe>)标签的XUL窗口下才会用到.最常用到的地方就是Firefox的主窗口, browser.xul. 在这种情况下, content 返回一个浏览器中的当前页面的Window对象的引用.相当于browserRef.contentWindow的快捷方式.

+

在一个非特权的内容窗口中 (网页), content 等同于普通的 top (除非网页是在侧边栏中加载的, content仍然会指向当前标签页中的Window对象).

+

一些旧的代码示例中使用了 _content 而不是 content.该形式的属性名已经被废弃很久了,你应该在新的代码中使用content.

+

语法

+
var windowObject = window.content;
+
+

例子

+

在一个拥有<browser type="content-primary"/>标签的chrome XUL 窗口下运行下面的代码.会在浏览器当前显示的页面上的第一个div标签上添加一个红色的边框:

+
content.document.getElementsByTagName("div")[0].style.border = "solid red 1px";
+
+

规范

+

不属于W3C规范.

+

相关链接

+ +
+  
+

{{ languages( { "fr": "fr/DOM/window.content", "ja": "ja/DOM/window.content", "pl": "pl/DOM/window.content" } ) }}

-- cgit v1.2.3-54-g00ecf