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 July 2015.

scriptsDocument インターフェイスのプロパティで、文書中の <script> 要素のリストを返します。返されるオブジェクトは単一の HTMLCollection オブジェクトです。

HTMLCollection です。これを使用して、リスト中のすべての要素を配列のように取得することができます。

ページ内の <script> 要素の存在を確認する例を以下に示します。

js
let scripts = document.scripts;

if (scripts.length) {
  alert("このページには script 要素があります。");
}

仕様書

Specification
HTML
# dom-document-scripts-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
scripts

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.