NotificationEvent: NotificationEvent() Konstruktor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since März 2023.
Hinweis: Diese Funktion ist nur in Service Workers verfügbar.
Der NotificationEvent() Konstruktor erstellt ein neues NotificationEvent-Objekt.
Syntax
new NotificationEvent(type, options)
Parameter
type-
Ein String mit dem Namen des Ereignisses. Dieser ist groß- und kleinschreibungssensitiv und Browser setzen ihn auf
notificationclickodernotificationclose. options-
Ein Objekt, das zusätzlich zu den in
ExtendableEvent()definierten Eigenschaften die folgenden Eigenschaften haben kann:notification-
Ein
Notification-Objekt, das als die Benachrichtigung verwendet wird, auf der das Ereignis ausgelöst wird. actionOptional-
Eine mit der Benachrichtigung verbundene Aktion. Standardmäßig ist es
"".
Rückgabewert
Ein neues NotificationEvent()-Objekt.
Beispiele
const n = new Notification("Hello");
const myNotificationEvent = new NotificationEvent(type, { notification: n });
Spezifikationen
| Specification |
|---|
| Notifications API> # dom-notificationevent-notificationevent> |