Easy Tutorial
❮ Event Ondragstart Prop Ins Datetime ❯

Script src Attribute

Script Object

Example

Retrieve the character set of an externally referenced script file:

var x = document.getElementById("myScript").charset

x output result:

UTF-8

Definition and Usage

The charset attribute specifies the character encoding used in an external script file.

The charset attribute is used when the character encoding of the external script file differs from the encoding of the HTML document.

Note: The charset attribute is only applicable to external scripts (only when the src attribute is used).


Browser Support

Attribute
charset Yes Yes Yes Yes Yes

Syntax

Return the charset attribute:

scriptObject.charset

Set the charset attribute:

scriptObject.charset=charset

Attribute Values

Value Description
charset Specifies the character encoding for the external script file. Some common values: "ISO-8859-1" - Standard encoding for the Latin alphabet "UTF-8" - Unicode character encoding, compatible with ASCII. Refer to our Character Sets Reference for a complete list of character sets.

Technical Details

| Return Value: | String, returns the character set used by the external script file. | | --- | --- |


Script Object

❮ Event Ondragstart Prop Ins Datetime ❯