非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
注意
: Since Firefox 57 (initially Nightly-only), both the
content
and
_content
variants are only available to chrome (privileged) code, and not available to the web anymore.
返回
Window object
for the primary content window. This is useful in XUL windows that have a
<browser>
(或
tabbrowser
or
<iframe>
) with
type="content-primary"
attribute on it — the most famous example is Firefox main window,
browser.xul
。在这种情况下,
content
returns a reference to the
Window
object for the document currently displayed in the browser. It is a shortcut for
browserRef
.contentWindow
.
In unprivileged content (webpages),
content
is normally equivalent to
top
(except in the case of a webpage loaded in a sidebar,
content
still refers to the
Window
of the currently selected tab).
注意
: Some examples use
_content
而不是
content
. The former has been deprecated for a long time, and you should use
content
in any new code.
句法
var windowObject = window.content;
范例
Executing the following code in a chrome XUL window with a
<browser type="content-primary"/>
element in it draws a red border around the first div on the page currently displayed in the browser:
content.document.getElementsByTagName("div")[0].style.border = "solid red 1px";
规范
None.
另请参阅
- Working with windows in chrome code
- When accessing content documents from privileged code, be aware of XPCNativeWrappers .
元数据
- 最后修改: