title | short-title | slug | l10n | ||
---|---|---|---|---|---|
Document: scripts プロパティ |
scripts |
Web/API/Document/scripts |
|
{{APIRef("DOM")}}
scripts
は {{domxref("Document")}} インターフェイスのプロパティで、文書中の {{HTMLElement("script")}} 要素のリストを返します。返されるオブジェクトは単一の {{domxref("HTMLCollection")}} オブジェクトです。
{{domxref("HTMLCollection")}} です。これを使用して、リスト中のすべての要素を配列のように取得することができます。
ページ内の {{HTMLElement("script")}} 要素の存在を確認する例を以下に示します。
let scripts = document.scripts;
if (scripts.length) {
alert("このページには script 要素があります。");
}
{{Specifications}}
{{Compat}}