Document.charset - 文字エンコーディング
charsetは、Documentのプロパティです。ドキュメントの文字エンコーディングを返します。このプロパティは歴史的な理由で残されています。代わりにcharacterSetを使って下さい。
このAPIは非推奨です。新しくコードに加えず、代わりの手段を探して下さい。
概要
- 名前
- charset
- 所属
- Document
- IDL
readonly attribute DOMString charset; // historical alias of .characterSet
- 仕様書
- https://dom.spec.whatwg.org/#dom-document-charset
説明
文字エンコーディングを返す。読み取り専用なので、値を代入して変更することはできない。
デモ
Document.charsetのデモです。
<!-- このコードは編集できます。 -->
<!DOCTYPE html>
<html>
<body>
<script>
var value = document.charset ;
console.log( value ) ;
document.body.appendChild( new Text( value ) ) ;
</script>
</body>
</html>
サポート状況
Chrome | Firefox | Safari | Edge | IE | Opera | iOS Safari | Android |
---|---|---|---|---|---|---|---|
● | ● 44+ | ● | ● | ● 9+ | ● | ● | ● |
関連記事
- Document.getElementsByClassName()
- getElementsByClassName()は、Documentのメソッドです。class属性を指定して要素を取得します。
- Date.prototype.toLocaleDateString()
- Date.prototype.toLocaleDateString()は、インスタンスの日付部分までをローカライズした文字列に変換するメソッドです。
- Document.title
- titleは、Documentのプロパティです。ドキュメントのタイトルを返します。title要素の中身を反映しています。
- Document.characterSet
- characterSetは、Documentのプロパティです。ドキュメントの文字エンコーディングを返します。