showing results for - "var notification 3d new notification"
Louis
13 Jun 2020
1// request permission on page load
2document.addEventListener('DOMContentLoaded', function() {
3 if (!Notification) {
4  alert('Desktop notifications not available in your browser. Try Chromium.');
5  return;
6 }
7
8 if (Notification.permission !== 'granted')
9  Notification.requestPermission();
10});
11
12
13function notifyMe() {
14 if (Notification.permission !== 'granted')
15  Notification.requestPermission();
16 else {
17  var notification = new Notification('Notification title', {
18   icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
19   body: 'Hey there! You\'ve been notified!',
20  });
21  notification.onclick = function() {
22   window.open('http://stackoverflow.com/a/13328397/1269037');
23  };
24 }
25}