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 属性。

规范

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
fgColor
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.