document.fgColor

概述

已废弃
该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

fgColor属性用来获取或设置当前文档的前景色或者文本颜色.

语法

  var color = document.fgColor;
  document.fgColor = color;

参数

  • color 是一个颜色值,可以为一个颜色类型,比如"red",或者一个16进制RGB值,比如 "#ff0000".

例子

document.fgColor = "white";
document.bgColor = "darkblue";

备注

在Mozilla Firefox中,该属性的默认值是黑色.(black或者#000000).

document.fgColor 属性已经在DOM Level 2中被废弃.推荐使用的css属性为color (用法为 document.body.style.color = "red").

另外一个类似的属性是 document.body.text, 该属性也在 HTML 4.01 中被废弃,推荐使用CSS属性.

规范

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
fgColor
DeprecatedNon-standard
Chrome Full support 64
Notes
Full support 64
Notes
Notes Before Chrome 64, this property was accessed through the HTMLDocument alias.
Edge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support 64
Notes
Full support 64
Notes
Notes Before Chrome 64, this property was accessed through the HTMLDocument alias.
Chrome Android Full support 64
Notes
Full support 64
Notes
Notes Before Chrome 64, this property was accessed through the HTMLDocument alias.
Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.