Script src Property
Example
Get the character set of the externally referenced script file:
var x = document.getElementById("myScript").charset
x The output result is:
UTF-8
Try it »
Definition and Usage
The charset property specifies the character encoding used in 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
| property | |||||
|---|---|---|---|---|---|
| charset | Yes | Yes | Yes | Yes | Yes |
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 that returns the character set used by the external script file. |
|---|
Script Object