Script character Property
Example
Get the character set used in an external script file:
var x = document.getElementById("myScript").charset
x The output is:
UTF-8
Try it »
Definition and Usage
The charset property sets or returns the value of the charset attribute of the script.
The charset property specifies the character encoding used by the external script file.
The charset property is used when the character encoding in the external script file differs from the encoding in the HTML document.
**Note:** The charset property only applies to external scripts (only when the src attribute is used).
Browser support





All major browsers support the charset property.
Syntax
Return the charset property:
scriptObject
.charset
Set the charset property:
scriptObject
.charset=
charset
Attribute values
| Value | Description |
|---|---|
| charset | Specifies the character encoding of the external script file.
Some common values: |
See our character set reference manual, for a complete list of character sets.
|Technical Details
| Return Value: | A string representing the URL of the external script file. Returns the full URL, including the protocol (such as http://). |
|---|
Related Articles
HTML Reference Manual:HTML
Script Object