The SecurityPolicyViolationEvent() constructor creates a new SecurityPolicyViolationEvent object.
On this page
SecurityPolicyViolationEvent: SecurityPolicyViolationEvent() constructor
Syntax
js
new SecurityPolicyViolationEvent(type)
new SecurityPolicyViolationEvent(type, options)
Parameters
-
type -
A string with the name of the event. It is case-sensitive and browsers always set it to
securitypolicyviolation. optionsOptional-
An object that, in addition of the properties defined in
Event(), can have the following properties:blockedURIOptional-
The
blockedURIof theSecurityPolicyViolationEvent. If not included, the default value is"". columnNumberOptional-
The
columnNumberof theSecurityPolicyViolationEvent. If not included, the default value is0. -
disposition -
The
dispositionof theSecurityPolicyViolationEvent. -
documentURI -
The
documentURIof theSecurityPolicyViolationEvent. -
effectiveDirective -
The
effectiveDirectiveof theSecurityPolicyViolationEvent. lineNumberOptional-
The
lineNumberof theSecurityPolicyViolationEvent. If not included, the default value is0. -
originalPolicy -
The
originalPolicyof theSecurityPolicyViolationEvent. referrerOptional-
The
referrerof theSecurityPolicyViolationEvent. If not included, the default value is"". sampleOptional-
The
sampleof theSecurityPolicyViolationEvent. If not included, the default value is"". sourceFileOptional-
The
sourceFileof theSecurityPolicyViolationEvent. If not included, the default value is"". -
statusCode -
The
statusCodeof theSecurityPolicyViolationEvent. -
violatedDirective -
The
violatedDirectiveof theSecurityPolicyViolationEvent.
Return value
A new SecurityPolicyViolationEvent object.
Examples
js
let SPVEvt = new SecurityPolicyViolationEvent("foo", {
/* ... */
});
Specifications
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–2023 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