HTMLImageElement: attributionSrc property
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Thuộc tính attributionSrc của giao diện HTMLImageElement mà bạn muốn trình duyệt gửi tiêu đề Attribution-Reporting-Eligible cùng với yêu cầu hình ảnh. Nó phản ánh thuộc tính nội dung attributionsrc của phần tử <img>.
Xem API báo cáo phân bổ để biết thêm chi tiết.
Giá trị
Một chuỗi trống hoặc danh sách URL được phân tách bằng dấu cách. Để giải thích thuộc tính này, hãy xem tài liệu tham khảo HTML <img>.
Ví dụ
>Đặt một attributionSrc trống
<img src="advertising-image.png" />
const imgElem = document.querySelector("img");
imgElem.attributionSrc = "";
Đặt attributionSrc chứa URL
<img src="advertising-image.png" />
// encode the URLs in case they contain special characters
// such as '=' that would be improperly parsed.
const encodedUrlA = encodeURIComponent("https://a.example/register-source");
const encodedUrlB = encodeURIComponent("https://b.example/register-source");
const imgElem = document.querySelector("img");
imgElem.attributionSrc = `${encodedUrlA} ${encodedUrlB}`;
Thông số kỹ thuật
| Specification |
|---|
| Attribution Reporting> # dom-htmlattributionsrcelementutils-attributionsrc> |