dom / latest / securitypolicyviolationevent / securitypolicyviolationevent.html /

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 an eventInitDict, certain properties must be included (marked below with required):

  • blockedURI: The blockedURI of the SecurityPolicyViolationEvent. If not included, the default value is "".
  • columnNumber: The columnNumber of the SecurityPolicyViolationEvent. If not included, the default value is 0.
  • disposition: The disposition of the SecurityPolicyViolationEvent (required).
  • documentURI: The documentURI of the SecurityPolicyViolationEvent (required).
  • effectiveDirective: The effectiveDirective of the SecurityPolicyViolationEvent (required).
  • lineNumber: The lineNumber of the SecurityPolicyViolationEvent. If not included, the default value is 0.
  • originalPolicy: The originalPolicy of the SecurityPolicyViolationEvent (required).
  • referrer: The referrer of the SecurityPolicyViolationEvent. If not included, the default value is "".
  • sample: The sample of the SecurityPolicyViolationEvent. If not included, the default value is "".
  • sourceFile: The sourceFile of the SecurityPolicyViolationEvent. If not included, the default value is "".
  • statusCode: The statusCode of the SecurityPolicyViolationEvent (required).
  • violatedDirective: The violatedDirective of the SecurityPolicyViolationEvent (required).

Return value

A SecurityPolicyViolationEvent object instance.

Examples

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–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