HTMLImageElement: referrerPolicy property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("HTML DOM")}}
The **referrerPolicy** property of the {{domxref("HTMLImageElement")}} interface defines which referrer is sent when fetching the resource. It reflects the <img> element's [referrerpolicy](/en-US/docs/Web/HTML/Reference/Elements/img#referrerpolicy) content attribute.
Value
A string whose value is one of no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, or unsafe-url. For their meanings, see the HTML [<img>](/en-US/docs/Web/HTML/Reference/Elements/img#referrerpolicy) reference.
Examples
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 referrerSpecifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("HTMLAnchorElement.referrerPolicy")}}
- {{domxref("HTMLAreaElement.referrerPolicy")}}
- {{domxref("HTMLIFrameElement.referrerPolicy")}}