SecurityPolicyViolationEvent()
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The SecurityPolicyViolationEvent constructor creates a new SecurityPolicyViolationEvent object instance.
Syntax
new SecurityPolicyViolationEvent(type); new SecurityPolicyViolationEvent(type, init);
Properties
- type
-
A
DOMStringrepresenting the type of security policy violation that occurred. - init Optional
-
An object containing information about the properties of the
SecurityPolicyViolationEventto be constructed. This can include the following properties, but bear in mind that if you do include aneventInitDict, certain properties must be included (marked below with required):-
blockedURI: TheblockedURIof theSecurityPolicyViolationEvent. If not included, the default value is"". -
columnNumber: ThecolumnNumberof theSecurityPolicyViolationEvent. If not included, the default value is0. -
disposition: Thedispositionof theSecurityPolicyViolationEvent(required). -
documentURI: ThedocumentURIof theSecurityPolicyViolationEvent(required). -
effectiveDirective: TheeffectiveDirectiveof theSecurityPolicyViolationEvent(required). -
lineNumber: ThelineNumberof theSecurityPolicyViolationEvent. If not included, the default value is0. -
originalPolicy: TheoriginalPolicyof theSecurityPolicyViolationEvent(required). -
referrer: Thereferrerof theSecurityPolicyViolationEvent. If not included, the default value is"". -
sample: Thesampleof theSecurityPolicyViolationEvent. If not included, the default value is"". -
sourceFile: ThesourceFileof theSecurityPolicyViolationEvent. If not included, the default value is"". -
statusCode: ThestatusCodeof theSecurityPolicyViolationEvent(required). -
violatedDirective: TheviolatedDirectiveof theSecurityPolicyViolationEvent(required).
-
Return value
A SecurityPolicyViolationEvent object instance.
Example
let SPVEvt = new SecurityPolicyViolationEvent('foo', { ... });
Specifications
| Specification |
|---|
| Content Security Policy Level 3 (Content Security Policy 3) # dom-securitypolicyviolationevent-securitypolicyviolationevent |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
SecurityPolicyViolationEvent |
41 |
15 |
63 |
No |
28 |
10 |
41 |
41 |
63 |
28 |
10 |
4.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent/SecurityPolicyViolationEvent