HTMLScriptElement: type プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
type
は HTMLScriptElement
インターフェイスのプロパティで、スクリプトの種類を反映する文字列です。
これは <script>
要素の type
属性を反映したものです。
値
文字列です。このプロパティの値は以下のいずれかです。
- 属性が設定されていない (既定値)、空文字列、JavaScript の MIME タイプのいずれか
-
スクリプトが JavaScript コードを格納した「クラシックスクリプト」であることを示します。
module
-
この値によってコードは JavaScript モジュールとして扱われます。
importmap
-
この値は、要素本体にインポートマップが含まれていることを示します。
speculationrules
Experimental-
この値は、要素の本体に投機ルールが含まれていることを示します。
- その他の値
-
埋め込まれたコンテンツはデータブロックとして扱われ、ブラウザーによって処理されることはありません。
例
html
<script id="el" type="text/javascript"></script>
js
const el = document.getElementById("el");
console.log(el.type); // 出力: "text/javascript"
仕様書
Specification |
---|
HTML # dom-script-type |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.