From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/document/scripts/index.html | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 files/ja/web/api/document/scripts/index.html (limited to 'files/ja/web/api/document/scripts') diff --git a/files/ja/web/api/document/scripts/index.html b/files/ja/web/api/document/scripts/index.html new file mode 100644 index 0000000000..c89053e06c --- /dev/null +++ b/files/ja/web/api/document/scripts/index.html @@ -0,0 +1,61 @@ +--- +title: Document.scripts +slug: Web/API/Document/scripts +tags: + - API + - Document + - HTML DOM + - Property + - Reference + - Script + - プロパティ +translation_of: Web/API/Document/scripts +--- +
{{APIRef("DOM")}}
+ +

{{domxref("Document")}} インターフェイスの scripts プロパティは、文書中の {{HTMLElement("script")}} 要素のリストを返します。返されるオブジェクトは単一の {{domxref("HTMLCollection")}} オブジェクトです。

+ +

構文

+ +
var scriptList = document.scripts;
+
+ +

+ +

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

+ +

+ +

ページ内の {{HTMLElement("script")}} 要素の存在を確認する例を以下に示します。

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

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG', '#dom-document-scripts', 'Document.scripts')}}{{ Spec2('HTML WHATWG') }} 
+ +

ブラウザーの対応

+ + + +
{{Compat("api.Document.scripts")}}
-- cgit v1.2.3-54-g00ecf