You are here: Reference > JavaScript > client-side > HTML DOM > properties > inputEncoding (document, XMLDocument)

inputEncoding property (document, XMLDocument)

Browser support:
9
Returns the character encoding used for parsing the document.
Note: The inputEncoding property is supported in Internet Explorer from version 9.
To get the character encoding of the document, use the document.charset and the document.characterSet properties. To get the character set that belongs to the current regional and language settings of the operating system, use the defaultCharset property.

Syntax:

object.inputEncoding;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

String that represents the character set. For more information, see the page for character sets.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the inputEncoding property:
<!DOCTYPE html>
<head>
    <meta charset="utf-8" />
    <script type="text/javascript">
        function GetCharSet () {
            var message = "";

            var docCharSet = document.characterSet ? document.characterSet : document.charset;
            message += "The character encoding of the document: <b>" + docCharSet + "</b><br />";

            if (document.defaultCharset) {
                message += "The character encoding that belongs to the operating system:  <b>" + document.defaultCharset + "</b><br />";
            }
            if (document.inputEncoding) {
                message += "The character encoding used for parsing the document:  <b>" + document.inputEncoding + "</b><br />";
            }

            var info = document.getElementById ("info");
            info.innerHTML = message;
        }
    </script>
</head>
<body onload="GetCharSet ()">
    <div id="info" style="width:500px; background-color:#e0d0d0;"></div>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content