InterventionReportBody: id 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

注意:此功能在 Web Workers 中可用。

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

id 只读属性是 InterventionReportBody 接口的一部分,它返回一个字符串,用于标识生成报告的干预措施。这可用于对报告进行分组。

字符串。

示例

在此示例中,我们创建一个新的 ReportingObserver 来观察干预措施报告,然后将 id 的值打印到控制台。

js
const options = {
  types: ["intervention"],
  buffered: true,
};

const observer = new ReportingObserver((reports, observer) => {
  const firstReport = reports[0];
  console.log(firstReport.type); // intervention
  console.log(firstReport.body.id);
}, options);

规范

规范
干预报告
# dom-interventionreportbody-id

浏览器兼容性