files/en-us/web/api/htmlscriptelement/referrerpolicy/index.md
{{APIRef("HTML DOM")}}
The referrerPolicy property of the
{{domxref("HTMLScriptElement")}} interface reflects the HTML
referrerpolicy of the {{HTMLElement("script")}} element, which defines how the referrer is set when fetching the script and any scripts it imports.
A string; one of the following:
no-referrer
no-referrer-when-downgrade
origin
https://example.com/page.html will send the referrer
https://example.com/.origin-when-cross-origin
same-origin
strict-origin
strict-origin-when-cross-origin (default)
unsafe-url
[!NOTE] An empty string value (
"") is both the default value, and a fallback value ifreferrerpolicyis not supported. Ifreferrerpolicyis not explicitly specified on the<script>element, it will adopt a higher-level referrer policy, i.e., one set on the whole document or domain. If a higher-level policy is not available, the empty string is treated as being equivalent tono-referrer-when-downgrade.
const scriptElem = document.createElement("script");
scriptElem.src = "/";
scriptElem.referrerPolicy = "unsafe-url";
document.body.appendChild(scriptElem);
{{Specifications}}
{{Compat}}