JavaScript

Using Notification API In JavaScript

Here, we will learn about how to use Notification API to display a desktop notification in the user’s browser.

What is Notification API?

The interface Notification of Notification API is used to display and configure desktop notification in the user’s browser. It is used to provide some information to users and generally, it works asynchronously

Code to be used for enabling desktop notification.

<!DOCTYPE html>
<html>
<head>
  <title>Desktop Notifications</title>
  <style type="text/css">
    .btnShowNotification{
      padding: 10px;
      background: orange;
      border: navajowhite;
      border-radius: 4px;
      color: #fff;
    }
  </style>
</head>
<body>
  <button class="btnShowNotification" >

We should allow the browser for displaying a notification in order to get the notification from the browser. It will check every time if Notification is granted or not. If it is not granted then it will again request for permission.

There are also various options for the Notification. You can refer them to the official website from here

Code in action:

Shaikh Irshad

Sr .NET Developer

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago