mozilla
Your Search Results

    Document.characterSet

    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. The former is deprecated in Chrome.

    Specifications

    See: document.characterSet and the Encoding Standard.

    Document Tags and Contributors

    Contributors to this page:
    Last updated by: jpmedley,
    Hide Sidebar