スクリプト文字セットプロパティ
例
外部スクリプトファイルで使用されている文字セットを取得します。
var x = document.getElementById("myScript").charset
定義と使用法
charsetプロパティは、スクリプトのcharset属性の値を設定または返します。
charset属性は、外部スクリプトファイルで使用される文字エンコードを指定します。
charset属性は、外部スクリプトファイルの文字エンコードがHTMLドキュメントのエンコードと異なる場合に使用されます。
注: charset属性は、外部スクリプト専用です(src属性が存在する場合にのみ使用できます)。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
charset | Yes | Yes | Yes | Yes | Yes |
構文
charsetプロパティを返します。
scriptObject.charset
charsetプロパティを設定します。
scriptObject.charset = charset
プロパティ値
Value | Description |
---|---|
charset | Specifies the character encoding of an external script file.
Some common values:
Look at our Character-sets reference for a complete list of character sets. |
技術的な詳細
戻り値: | 外部スクリプトファイルのURLを表す文字列。プロトコル(http://など)を含むURL全体を返します |
---|
関連ページ
HTMLリファレンス:HTML <script>文字セット属性
❮スクリプトオブジェクト