aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/document/fgcolor/index.html
blob: 07da4e193399829e921306c79508e38ebeaec506 (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
---
title: Document.fgColor
slug: Web/API/Document/fgColor
tags:
  - API
  - DOM
  - Deprecated
  - Document
  - HTML DOM
  - Reference
  - fgColor
  - プロパティ
translation_of: Web/API/Document/fgColor
---
<div>{{ApiRef}}{{Deprecated_header}}</div>

<p><strong><code>fgColor</code></strong> は、現在の文書の前景色またはテキストの色を取得または設定します。</p>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox">var <var>color</var> = <var>document</var>.fgColor;
<var>document</var>.fgColor = <var>color;</var>
</pre>

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

<ul>
 <li><code>color</code> は文字列で、色を表すキーワード ("red" など) または16進数の値 (<code>"#000000"</code> など) です。</li>
</ul>

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

<pre class="brush:js">document.fgColor = "white";
document.bgColor = "darkblue";
</pre>

<h2 id="Notes" name="Notes">メモ</h2>

<p>Mozilla Firefox ではこのプロパティの既定値は黒 (16進数で <code>#000000</code>) です。</p>

<p><code>document.fgColor</code><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268">DOM Level 2 HTML で非推奨</a>となっています。推奨される代替手段は CSS プロパティの {{Cssxref("color")}} (たとえば <code>document.body.style.color = "red"</code>) です。</p>

<p>他の代替手段として <code>document.body.text</code> がありますが、上記の CSS による代替手段が設置されたため <a href="http://www.w3.org/TR/html401/struct/global.html#adef-text">HTML 4.01 で非推奨</a>となっています。</p>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2>

<p>{{Compat("api.Document.fgColor")}}</p>