--- title: Document.scripts slug: Web/API/Document/scripts translation_of: Web/API/Document/scripts ---
{{ ApiRef() }}
返回一个{{ domxref("HTMLCollection") }}对象,包含了当前文档中所有{{ HTMLElement("script") }}元素的集合.
var scriptList
= document.scripts;
scriptList是一个
{{ domxref("HTMLCollection") }}对象.你可以像使用数组一样通过索引来获取其中包含的{{ HTMLElement("script") }}元素.
下例演示了如何查看当前页面是否包含有{{ HTMLElement("script") }}元素.
var scripts = document.scripts; if (scripts.length) { alert("该页面存在script标签!"); }