@newfivefour/

notification-api

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<body>
  <button onclick="notify()">Notify me</button>

  <script>

    function notify() {

      if (!("Notification" in window)) {
        alert("This browser does not support system notifications");
      } else {
        Notification.requestPermission().then(function(result) {
          if (result === "granted") {
            new Notification("Hi there!");
          } else {
            console.log("permission was not granted.")
          }
        });
      }
        
    }

  </script>

</body>
result
console