document.characterSet

Did you know that you can read content offline by using one of these tools? If you would like to read offline MDN content in another format, let us know by commenting on Bug 665750.

Dash App

« DOM Reference

Summary

Returns the character encoding of the current document.

Syntax

document.characterSet

Examples

var string = document.characterSet;
<button onclick="alert(document.characterSet);">Show character set</button>
// returns document's character set, such as "ISO-8859-1" or "UTF-8"

Notes

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 related, nonstandard method document.charset and the property document.defaultCharset are not supported by Gecko.

Specification

See: document.characterSet and the Encoding Standard.

Tags (3)