大网数据广告活动
Web 标准与前端开发

`<meta name="referrer">` HTML attribute value

· 52CE 我爱测

The **`referrer`** value for the `name` attribute of the meta element controls the HTTP Referer header of requests sent from the document. If specified, you define the referrer using a `content` attribute in the `<meta>` element as a keyword value.

The referrer value for the name attribute of the meta element controls the HTTP Referer header of requests sent from the document. If specified, you define the referrer using a content attribute in the <meta> element as a keyword value.

For example, the following <meta> element sends the origin of the document as the referrer:

<meta name="referrer" content="origin" />

[!WARNING] Dynamically inserting <meta name="referrer"> (with Document.write or Node.appendChild) makes the referrer behavior unpredictable. When several conflicting policies are defined, the no-referrer policy is applied.

Usage notes

A <meta name="referrer"> element has the following additional attributes:

  • content
    • : Sets the document referrer. You must define this attribute. Accepts one of the following values:
      • no-referrer
        • : Does not send an HTTP Referer header.
      • origin
        • : Sends the origin of the document.
      • no-referrer-when-downgrade
        • : Sends the full URL when the destination is at least as secure as the current page (HTTP(S)→HTTPS), but sends no referrer when it's less secure (HTTPS→HTTP). This is the default behavior.
      • origin-when-cross-origin
        • : Sends the full URL (stripped of parameters) for same-origin requests, but only sends the origin for other cases.
      • same-origin
        • : Sends the full URL (stripped of parameters) for same-origin requests. Cross-origin requests will contain no referrer header.
      • strict-origin
        • : Sends the origin when the destination is at least as secure as the current page (HTTP(S)→HTTPS), but sends no referrer when it's less secure (HTTPS→HTTP).
      • strict-origin-when-cross-origin
        • : Sends the full URL (stripped of parameters) for same-origin requests. Sends the origin when the destination is at least as secure as the current page (HTTP(S)→HTTPS). Otherwise, sends no referrer.
      • unsafe-URL
        • : Sends the full URL (stripped of parameters) for same-origin or cross-origin requests.

Examples

Removing a referrer from requests

The following <meta> element specifies that the document shouldn't send a Referer header with HTTP requests from the document:

<meta name="referrer" content="no-referrer" />

Specifications

Browser compatibility

See also

  • HTTP Referer header

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。