NotificationEvent: NotificationEvent() コンストラクター
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年3月.
メモ: この機能はサービスワーカー内でのみ利用可能です。
NotificationEvent() コンストラクターは、新しい NotificationEvent オブジェクトを生成します。
構文
js
new NotificationEvent(type, options)
引数
type-
イベントの名前の文字列。 大文字と小文字が区別され、ブラウザーでは
notificationclickまたはnotificationcloseに設定します。 options-
オブジェクトで、
ExtendableEvent()で定義されているプロパティに加え、以下のプロパティを持つことができます。notification-
イベントが配信される際に通知として使用する
Notificationオブジェクト。 action省略可-
通知に関連付けられたアクション。既定では
""です。
返値
新しい NotificationEvent() オブジェクトです。
例
js
const n = new Notification("Hello");
const myNotificationEvent = new NotificationEvent(type, { notification: n });
仕様書
| Specification |
|---|
| Notifications API> # dom-notificationevent-notificationevent> |