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
DOMString
representing the type of security policy violation that occurred. - init Optional
-
An object containing information about the properties of the
SecurityPolicyViolationEvent
to 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
: TheblockedURI
of theSecurityPolicyViolationEvent
. If not included, the default value is""
. -
columnNumber
: ThecolumnNumber
of theSecurityPolicyViolationEvent
. If not included, the default value is0
. -
disposition
: Thedisposition
of theSecurityPolicyViolationEvent
(required). -
documentURI
: ThedocumentURI
of theSecurityPolicyViolationEvent
(required). -
effectiveDirective
: TheeffectiveDirective
of theSecurityPolicyViolationEvent
(required). -
lineNumber
: ThelineNumber
of theSecurityPolicyViolationEvent
. If not included, the default value is0
. -
originalPolicy
: TheoriginalPolicy
of theSecurityPolicyViolationEvent
(required). -
referrer
: Thereferrer
of theSecurityPolicyViolationEvent
. If not included, the default value is""
. -
sample
: Thesample
of theSecurityPolicyViolationEvent
. If not included, the default value is""
. -
sourceFile
: ThesourceFile
of theSecurityPolicyViolationEvent
. If not included, the default value is""
. -
statusCode
: ThestatusCode
of theSecurityPolicyViolationEvent
(required). -
violatedDirective
: TheviolatedDirective
of 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