setStringValue() 方法在 CSSPrimitiveValue interface is used to set a string value. If the property attached to this value can't accept the specified unit or the string value, the value will be unchanged and a DOMException 会被引发。

句法

cssPrimitiveValue.setStringValue(stringType, stringValue);
					

参数

stringType
An unsigned short representing the type of the value. Possible values are:
常量 描述
CSS_ATTR The value is an attr() 函数。
CSS_IDENT The value is an identifier.
CSS_STRING The value is a <string> .
CSS_URI The value is a <uri> .
stringValue
DOMString representing the new string value.

返回值

Void.

异常

类型 描述
DOMException An INVALID_ACCESS_ERR is raised if the CSS value doesn't contain a string value or if the string value can't be converted into the specified unit.
An NO_MODIFICATION_ALLOWED_ERR is raised if this property is read-only.

规范

规范 状态 注释
Document Object Model (DOM) Level 2 Style Specification
The definition of 'CSSPrimitiveValue.setStringValue' in that specification.
过时 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
setStringValue 弃用 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

图例

不支持

不支持

兼容性未知 ?

兼容性未知

弃用。不要用于新网站。

弃用。不要用于新网站。

元数据

  • 最后修改: