javascript click event notifications 1

javascript click event notifications

var message = new Notification("RandomString");
message.onclick = function(){
    alert("Random Message")
};

Here is what the above code is Doing:
1. We are creating a new Notification object.
2. We are setting the onclick property of the Notification object to a function that will alert a message.
3. We are calling the show() method of the Notification object.

The Notification object has a few more properties and methods that you can use to customize the notification.

The Notification object has the following properties:

1. dir: This property specifies the direction of the notification. It can be either auto, ltr, or rtl.
2. lang: This property specifies the language of the notification.
3. body: This property specifies the body of the notification.
4. tag: This property specifies the tag of the notification.
5. icon: This property specifies the icon of the notification.

The Notification object has the following methods:

1. close(): This method closes the notification.
2. addEventListener(): This method adds an event listener to the notification.
3. removeEventListener(): This method removes an event listener from the notification.

The Notification object has the following events:

1. onclick: This event is fired when the user clicks on the notification.
2. onerror: This event is fired when an error occurs.
3. onclose: This event is fired when the notification is closed.
4. onshow: This event is fired when the notification is shown.

Similar Posts