Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Document.scripts

概述

返回一个HTMLCollection对象,包含了当前文档中所有<script>元素的集合.

语法

var scriptList = document.scripts;

scriptList是一个HTMLCollection对象.你可以像使用数组一样通过索引来获取其中包含的<script>元素.

例子

下例演示了如何查看当前页面是否包含有<script>元素.

var scripts = document.scripts;

if (scripts.length) {
  alert("该页面存在script标签!");
}

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 9.0 (9.0) (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 9.0 (9.0) (Yes) (Yes) (Yes)

规范

DOM: document scripts

文档标签和贡献者

 此页面的贡献者: teoli, jsx, AlexChao, ziyunfei
 最后编辑者: jsx,