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
- Document Object Model (DOM) Level 1 Specification, Section 2.5.5
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]