Document:characterSet 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Document.characterSet 只读属性返回当前渲染文档字符编码

备注: “字符集”和“字符编码”是相关的,但又有所不同。尽管这个属性的名称如此,但它返回的是编码

一个字符串。

示例

html
<button onclick="console.log(document.characterSet);">输出字符编码</button>
<!-- 在开发控制台中显示文档字符编码,例如“ISO-8859-1”或“UTF-8” -->

规范

Specification
DOM Standard
# ref-for-dom-document-characterset①

浏览器兼容性

BCD tables only load in the browser