SecurityPolicyViolationEvent: effectiveDirective 属性

Baseline 已广泛支持

此特性已成熟稳定,适用于多种设备和浏览器版本。自 2018 年 10 月起,它已在各浏览器中可用。

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

SecurityPolicyViolationEvent 接口的 effectiveDirective 只读属性是一个字符串,表示被违反的 内容安全策略 (CSP) 指令。

此属性取代了其历史别名 SecurityPolicyViolationEvent.violatedDirective

一个字符串,表示被违反的特定 Content-Security-Policy 指令

示例

js
document.addEventListener("securitypolicyviolation", (e) => {
  console.log(e.effectiveDirective);
});

规范

规范
内容安全策略级别 3
# dom-securitypolicyviolationevent-effectivedirective

浏览器兼容性

另见