NotificationEvent: NotificationEvent() constructor

The NotificationEvent() constructor creates a new NotificationEvent object.

Syntax

new NotificationEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers set it to notificationclick or notificationclose.

options

An object that, in addition of the properties defined in ExtendableEvent(), can have the following properties:

notification

A Notification object to be used as the notification the event is dispatched on.

action Optional

An action associated with the notification. It defaults to "".

Return value

A new NotificationEvent() object.

Examples

const n = new Notification("Hello");
const myNotificationEvent = new NotificationEvent(type, { notification: n });

Specifications

Specification
Notifications API Standard
# dom-notificationevent-notificationevent

Browser compatibility

BCD tables only load in the browser