Document: scripts プロパティ
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年6月.
scripts
は Document
インターフェイスのプロパティで、文書中の <script>
要素のリストを返します。返されるオブジェクトは単一の HTMLCollection
オブジェクトです。
値
HTMLCollection
です。これを使用して、リスト中のすべての要素を配列のように取得することができます。
例
ページ内の <script>
要素の存在を確認する例を以下に示します。
js
let scripts = document.scripts;
if (scripts.length) {
alert("このページには script 要素があります。");
}
仕様書
Specification |
---|
HTML> # dom-document-scripts-dev> |
ブラウザーの互換性
Loading…