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.
Syntax
var string = document.characterSet
Examples
<button onclick="console.log(document.characterSet);"> Show character set </button> <!-- logs document's character set, such as "ISO-8859-1" or "UTF-8" -->
Specifications
Specification | Status | Comment |
---|---|---|
DOM The definition of 'characterSet' in that specification. |
Living Standard | Initial definition. |
Browser compatibility
Document Tags and Contributors
Tags:
Contributors to this page:
arronei,
erikadoyle,
teoli,
elia,
chrisdmiddleton,
Sebastianz,
fscholz,
jsx,
jpmedley,
kosvrouvas,
kscarfone,
Cobra,
Sheppy,
Annevk,
ziyunfei,
Matej Lednar,
MatrixFrog,
George3,
DR,
Nickolay,
Jabez,
Takenbot,
Dria,
cbiesinger,
JesseW
Last updated by:
arronei,