NotificationEvent: NotificationEvent() コンストラクター
メモ: この機能はサービスワーカー内でのみ利用可能です。
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 |
ブラウザーの互換性
BCD tables only load in the browser