HTMLImageElement: referrerPolicy property

Baseline Widely available *

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

* Some parts of this feature may have varying levels of support.

Thuộc tính referrerPolicy của giao diện HTMLImageElement xác định liên kết giới thiệu nào được gửi khi tìm nạp tài nguyên. Nó phản ánh thuộc tính nội dung referrerpolicy của phần tử <img>.

Giá trị

Một chuỗi có giá trị là một trong no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin hoặc unsafe-url. Để biết ý nghĩa của chúng, hãy xem tài liệu tham khảo HTML <img>.

Ví dụ

js
const img = new Image();
img.src = "img/logo.png";
img.referrerPolicy = "origin";

const div = document.getElementById("divAround");
div.appendChild(img); // Fetch the image using the origin as the referrer

Thông số kỹ thuật

Thông số kỹ thuật
HTML
# dom-img-referrerpolicy

Khả năng tương thích của trình duyệt

Xem thêm