Created
December 15, 2014 19:57
-
-
Save prasanthj/cd5b54b91249e2643f46 to your computer and use it in GitHub Desktop.
Browser notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function notifyMe(url) { | |
if (!Notification) { | |
alert('Notifications are supported in modern versions of Chrome, Firefox, Opera and Firefox.'); | |
return; | |
} | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
var notification = new Notification('Site is up!', { | |
icon: 'thumbs-up.png', | |
body: "Hey there! " + url + " is back online now!", | |
}); | |
notification.onclick = function () { | |
window.open(url); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment