HTML <img> referrerpolicy Attribute

Definition and Usage

referrerpolicy The attribute specifies the reference information to be used when fetching the image.

Example

Set the referrerpolicy for the image:

<img src="https://example.com/images/myimage.jpg" alt="Some image" referrerpolicy="no-referrer">

语法

<img referrerpolicy="no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|unsafe-url">

属性值

描述
no-referrer 不发送引用者信息。
no-referrer-when-downgrade 默认。引用者标头不会被发送到没有 HTTPS 的源。
origin 发送文档的来源(协议、主机和端口)。
origin-when-cross-origin 对于跨源请求:仅发送协议、主机和端口。对于同源请求:还包括路径。
unsafe-url 发送来源、路径和查询字符串(但不包括片段、密码或用户名)。该值被认为是不安全的。

浏览器支持

表中的数字注明了首个完全支持该属性的浏览器版本。

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
51.0 79.0 50.0 11.1 38.0