HTMLImageElement: attributionSrc-Eigenschaft
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Sicherer Kontext: Diese Funktion ist nur in sicheren Kontexten (HTTPS) in einigen oder allen unterstützenden Browsern verfügbar.
Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.
Die attributionSrc-Eigenschaft des HTMLImageElement Interfaces gibt an, dass Sie möchten, dass der Browser einen Attribution-Reporting-Eligible-Header zusammen mit der Bildanfrage sendet. Sie spiegelt das attributionsrc-Inhaltsattribut des <img>-Elements wider.
Weitere Informationen finden Sie in der Attribution Reporting API.
Wert
Ein String, der entweder leer ist oder eine durch Leerzeichen getrennte Liste von URLs enthält. Für die Interpretation dieses Attributs siehe die HTML-Referenz des <img>-Elements.
Beispiele
>Ein leeres attributionSrc setzen
<img src="advertising-image.png" />
const imgElem = document.querySelector("img");
imgElem.attributionSrc = "";
Ein attributionSrc mit URLs setzen
<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}`;
Spezifikationen
| Specification |
|---|
| Attribution Reporting> # dom-htmlattributionsrcelementutils-attributionsrc> |