HTML <img> referrerpolicy 属性
示例
设置图片的 referrerpolicy
<img src="https://example.com/images/myimage.jpg" alt="一张图片" referrerpolicy="no-referrer">
定义和用法
referrerpolicy
属性指定了在获取图片时应使用哪些引用者信息。
浏览器支持
表格中的数字表示完全支持该属性的第一个浏览器版本。
Attribute | |||||
---|---|---|---|---|---|
referrerpolicy | 51.0 | 79.0 | 50.0 | 11.1 | 38.0 |
语法
<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 | 执行同域请求时发送源、路径和查询字符串(但不包括片段、密码或用户名)。此值被视为不安全。 |
❮ HTML <a> 标签