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.
ThereferrerPolicy property of theHTMLImageElement interface defining which referrer is sent when fetching the resource. It reflects the<img> element'sreferrerpolicy content attribute.
In this article
Value
A string whose value is one ofno-referrer,no-referrer-when-downgrade,origin,origin-when-cross-origin,same-origin,strict-origin,strict-origin-when-cross-origin, orunsafe-url. For their meanings, see the HTML<img> 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
| Specification |
|---|
| HTML> # dom-img-referrerpolicy> |