This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2018.
Note: This feature is available in Web Workers.
The statusCode read-only property of the SecurityPolicyViolationEvent interface is a number representing the HTTP status code of the window or worker in which the Content Security Policy (CSP) violation occurred.
A number representing the status code of the window or worker in which the violation occurred.
document.addEventListener("securitypolicyviolation", (e) => {
console.log(e.statusCode);
});
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
statusCode |
41 | 15 | 63 | 28 | 10 | 41 | 63 | 28 | 10 | 4.0 | 41 | 10 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent/statusCode