This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

charset

Summary

Gets or sets the preferred MIME name of the document’s character encoding.

Property of dom/Documentdom/Document

Syntax

var result = element.charset;
element.charset = value;

Examples

//displays the document's character encoding string
function showCharSet() {
    alert(document.characterSet);
}

//sets the document's character encoding string
function putCharSet() {
    document.characterSet = "UTF-16";
}

Usage

 On setting, if the new value is an IANA-registered alias for a character encoding supported by the user agent, the document's character encoding is set to that character encoding. Otherwise, nothing happens.

Notes

Remarks

For a, link, and script objects, you must set the value of this property before you can retrieve it. You must set the value of this property before you can retrieve it. In Microsoft Internet Explorer 6, This property now applies to the a, link, and script objects.

Syntax

Standards information

Attributions