getRGBColorValue()
方法在
CSSPrimitiveValue
interface is used to get an RGB color value. If this CSS value doesn't contain a RGB color value, a
DOMException
is raised. Modification to the corresponding style property can be achieved using the
RGBColor
接口。
var rgbColorValue = cssPrimitiveValue.getRGBColorValue();
RGBColor
object representing the color value.
| 类型 | 描述 |
|---|---|
DOMException
|
An
INVALID_ACCESS_ERR
is raised if the attached property can't return an RGB color value (i.e. this is not
CSS_RGBCOLOR
).
|
var cs = window.getComputedStyle(document.body);
var cssValue = cs.getPropertyCSSValue("color");
console.log(cssValue.getRGBColorValue());
| 规范 | 状态 | 注释 |
|---|---|---|
|
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSPrimitiveValue.getRGBColorValue' in that specification. |
过时 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getRGBColorValue
弃用
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 ? — 62 | IE ? | Opera 不支持 No | Safari ? | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 4 — 62 | Opera Android ? | Safari iOS ? | Samsung Internet Android 不支持 No |
不支持
兼容性未知
实验。期望将来行为有所改变。
弃用。不要用于新网站。
CSSPrimitiveValue
getCounterValue()
getFloatValue()
getRectValue()
getRGBColorValue()
getStringValue()
setFloatValue()
setStringValue()
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument