Document: bgColor プロパティ

非推奨;: この機能は非推奨になりました。まだ対応しているブラウザーがあるかもしれませんが、すでに関連するウェブ標準から削除されているか、削除の手続き中であるか、互換性のためだけに残されている可能性があります。使用を避け、できれば既存のコードは更新してください。このページの下部にある互換性一覧表を見て判断してください。この機能は突然動作しなくなる可能性があることに注意してください。

非推奨の bgColor プロパティは、現在の文書の背景色を取得または設定します。

文字列で、色を色名("white" 等)または 16 進値("#FFFFFF" 等)で表します。

js
document.bgColor = "darkblue";

メモ

Firefox ではこのプロパティの初期値は白 (16 進表記で #FFFFFF) となっています。

document.bgColorDOM Level 2 HTML で非推奨になっています。推奨される代替方法は、 CSS の background-color を使用することで、 document.body.style.backgroundColor で DOM を通してアクセスできます。もう一つの代替手段である document.body.bgColor は、 HTML 4.01 で CSS に代替されたため非推奨となっています。

仕様書

Specification
HTML
# dom-document-bgcolor

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
bgColor
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Deprecated. Not for use in new websites.
Has more compatibility info.