Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // request permission on page load
  2. document.addEventListener('DOMContentLoaded', function () {
  3. if (Notification.permission !== "granted")
  4. Notification.requestPermission();
  5. });
  6.  
  7. function notifyMe() {
  8. if (!Notification) {
  9. alert('Desktop notifications not available in your browser. Try Chromium.');
  10. return;
  11. }
  12.  
  13. if (Notification.permission !== "granted")
  14. Notification.requestPermission();
  15. else {
  16. var notification = new Notification('Notification title', {
  17. icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
  18. body: "Hey there! You've been notified!",
  19. });
  20.  
  21. notification.onclick = function () {
  22. window.open("http://stackoverflow.com/a/13328397/1269037");
  23. };
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement