The Document.characterSet
read-only property returns the character encoding of the current document. The character encoding is the character set used for rendering the document, which may be different from the encoding specified by the page. (The user can override the encoding.).
The properties document.charset
and document.inputEncoding
are legacy aliases for document.characterSet
. Do not use them anymore.
var string = document.characterSet
<button onclick="console.log(document.characterSet);"> Show character set </button> <!-- logs document's character set, such as "ISO-8859-1" or "UTF-8" -->
Specification | Status | Comment |
---|---|---|
DOM The definition of 'characterSet' in that specification. | Living Standard | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 45.0 | (Yes) | (Yes) | ? | ? | 9 (possibly earlier) |
charset | Made read-only in 45 | (Yes) | 44 (44) | ? | ? | 9 (possibly earlier) |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|---|
Basic support | No support | 45.0 | (Yes) | (Yes) | (Yes) | ? | ? | ? | 45.0 |
charset | ? | ? | (Yes) | 44.0 (44) | 2.5 | ? | ? | ? | ? |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/document/characterSet