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.

scriptsDocument인터페이스의 속성으로 문서 중<script> 요소의 목록을 반환합니다. 반환되는 객체는 단일 HTMLCollection 객체입니다.

HTMLCollection입니다. 이를 사용하여 목록의 모든 요소를 배열처럼 가져올 수 있습니다.

예제

다음은 페이지 내 <script> 요소의 존재를 확인하는 예시입니다.

js
let scripts = document.scripts;

if (scripts.length) {
  alert("This page has scripts!");
}

명세서

Specification
HTML
# dom-document-scripts-dev

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
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.