HTMLScriptElement: thuộc tính integrity

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.

Thuộc tính integrity của giao diện HTMLScriptElement là một chuỗi chứa siêu dữ liệu nội tuyến mà trình duyệt có thể dùng để xác minh rằng tài nguyên đã được tìm nạp và không bị can thiệp ngoài mong muốn.

Nó phản ánh thuộc tính integrity của phần tử <script>.

Giá trị

Một chuỗi.

Ví dụ

html
<script
  id="el"
  src="https://example.com/example-framework.js"
  integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
  crossorigin="anonymous"></script>
js
const el = document.getElementById("el");
console.log(el.integrity); // Kết quả: "sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"

Thông số kỹ thuật

Specification
HTML
# dom-script-integrity

Tương thích trình duyệt

Xem thêm