aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/bgcolor/index.html
blob: 75a7ffae9a71fb5204c53ea218ba40d8ffa464f9 (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
---
title: Document.bgColor
slug: Web/API/Document/bgColor
translation_of: Web/API/Document/bgColor
---
<p>{{APIRef("DOM")}}{{ Deprecated_header() }}</p>

<p> <code>bgColor</code> 获取/设置当前文档的背景颜色</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="eval"><em>color</em> = document.bgColor
document.bgColor =<em>color</em>
</pre>

<h3 id="Parameters" name="Parameters">参数</h3>

<ul>
 <li><code>color</code> 表示颜色的字符串如“red”,或者是十六进制的色值如“#ff0000”。</li>
</ul>

<h2 id="Example" name="Example">示例</h2>

<pre class="eval">document.bgColor = "darkblue";
</pre>

<h2 id="Notes" name="Notes">笔记</h2>

<p>这个属性在Mozilla Firefox中的默认值是白色”#ffffff“。</p>

<p><code>document.bgColor</code> 在 <a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268">DOM Level 2 HTML</a> 中已经不推荐使用。 推荐使用CSS的 <a href="en/CSS/background-color">background-color</a> 或者 <code>document.body.style.backgroundColor 来给文档设置背景颜色。</code> 另外一种方式是使用 <code>document.body.bgColor</code>, 这种方式也已经不推荐使用了。</p>