Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WorkerGlobalScope
  4. securitypolicyviolation

WorkerGlobalScope: securitypolicyviolation event

Baseline Widely available

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 only available inWeb Workers.

Thesecuritypolicyviolation event is fired when aContent Security Policy is violated in a worker.

The handler can be assigned using theonsecuritypolicyviolation event handler property or usingEventTarget.addEventListener().

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("securitypolicyviolation", (event) => { })onsecuritypolicyviolation = (event) => { }

Event type

ASecurityPolicyViolationEvent. Inherits fromEvent.

Event SecurityPolicyViolationEvent

Examples

The code below shows how you might add an event handler function using theonsecuritypolicyviolation event handler property or calladdEventListener() method.

js
self.onsecuritypolicyviolation = (e) => {  // Handle SecurityPolicyViolationEvent e here};self.addEventListener("securitypolicyviolation", (e) => {  // Handle SecurityPolicyViolationEvent e here});

Specifications

Specification
Content Security Policy Level 3
# eventdef-globaleventhandlers-securitypolicyviolation

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp