HTML DOM Script character attributes
Examples
Get the character set used in external script files:
var x = document.getElementById("myScript").charset
x The output is:
UTF-8
try it"
Definition and Usage
charset property sets or returns the value of charset attribute of the script.
charset attribute specifies the character encoding of an external script files.
When an external script file character encoding and HTML document coding is not the same, it will use charset attribute.
Note: charset attribute applies only to external script (only when using the src attribute).
Browser Support
All major browsers support the charset attribute.
grammar
Returns the charset attribute:
scriptObject .charset
Set the charset attribute:
scriptObject .charset= charset
Property Value
值 | 描述 |
---|---|
charset | 规定外部脚本文件的字符编码。
一些常用的值:
请参阅我们的 字符集参考手册 ,获得完整的字符集列表。 |
technical details
return value: | String that represents the URL of an external script file. Returns the complete URL, including the protocol (such as http: //). |
---|
related articles
HTML Reference Manual: HTML <Script> charset attribute