Created
February 29, 2012 14:50
-
-
Save robertcasanova/1941314 to your computer and use it in GitHub Desktop.
Notifications HTML5
This file contains 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
if (window.webkitNotifications) { | |
if (window.webkitNotifications.checkPermission() == 0) { | |
var note = window.webkitNotifications.createNotification("", "Hi", "I'm a notification"); | |
note.ondisplay = function(event) { | |
setTimeout(function() { | |
event.currentTarget.cancel(); | |
}, 2000); | |
} | |
note.show(); | |
} | |
else { | |
window.webkitNotifications.requestPermission(); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check this: http://www.html5rocks.com/en/tutorials/notifications/quick/