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.
scripts
は Document
インターフェイスのプロパティで、文書中の <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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
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.
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.