A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/zh-CN/docs/Web/API/HTMLAnchorElement/attributionSrc below:

HTMLAnchorElement:attributionSrc 属性 - Web API

HTMLAnchorElement:attributionSrc 属性

Limited availability

安全上下文: 此项功能仅在一些支持的浏览器的安全上下文(HTTPS)中可用。

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格。

HTMLAnchorElement 接口的 attributionSrc 属性用于以编程方式获取和设置 <a> 元素上的 attributionsrc 属性,反映该属性的值。attributionsrc 指定你希望浏览器发送 Attribution-Reporting-Eligible 标头。在服务器端,这用于触发在响应中发送 Attribution-Reporting-Register-Source 标头,以注册一个基于导航的归因来源。

当浏览器接收到导航响应时,它会存储与基于导航的归因来源相关联的源数据(如 Attribution-Reporting-Register-Source 响应标头中所提供的数据)。

参见归因报告 API 以获取更多详细信息。

备注: <a> 元素不能用作归因触发器,只能用作归因来源。

值

一个字符串。此属性有两个版本可供获取和设置:

示例 设置空的 attributionSrc
<a href="https://shop.example"> 点击访问我们的商店 </a>
const aElem = document.querySelector("a");
aElem.attributionSrc = "";
设置包含 URL 的 attributionSrc
<a href="https://ourshop.example"> 点击访问我们的商店 </a>
// 对 URL 进行编码,以防它们包含特殊字符
// 例如“=”,这种字符可能会被错误地解析。
const encodedUrlA = encodeURIComponent("https://a.example/register-source");
const encodedUrlB = encodeURIComponent("https://b.example/register-source");

const aElem = document.querySelector("a");
aElem.attributionSrc = `${encodedUrlA} ${encodedUrlB}`;
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4