This page was translated from English by the community. Learn more and join the MDN Web Docs community.
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 июнь 2018 г..
Возвращает список элементов <script> в документ. Возвращаемый объект является HTMLCollection.
Syntax
var scriptList = document.scripts;
Возвращаемый scriptList является HTMLCollection. Вы можете использовать его как массив для получения всех элементов в списке.
Example
Этот пример показывает есть ли на странице элементы <script>.
js
var scripts = document.scripts;
if (scripts.length) {
alert("This page has scripts!");
}
Спецификации
| Specification |
|---|
| HTML> # dom-document-scripts-dev> |
Совместимость с браузерами
Enable JavaScript to view this browser compatibility table.