Back to Content

SecurityPolicyViolationEvent: violatedDirective property

files/en-us/web/api/securitypolicyviolationevent/violateddirective/index.md

latest772 B
Original Source

{{APIRef("Reporting API")}}{{AvailableInWorkers}}

The violatedDirective read-only property of the {{domxref("SecurityPolicyViolationEvent")}} interface is a string representing the Content Security Policy (CSP) directive that was violated.

This is a historical alias of {{domxref("SecurityPolicyViolationEvent.effectiveDirective")}}, and has the same value.

Value

A string representing the Content-Security-Policy directive that was violated.

Examples

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

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}