Created
October 3, 2013 12:14
-
-
Save aronbudinszky/6808871 to your computer and use it in GitHub Desktop.
Chrome notifications as taken from http://stackoverflow.com/questions/2271156/chrome-desktop-notification-example
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
<script> | |
function notify() { | |
var havePermission = window.webkitNotifications.checkPermission(); | |
if (havePermission == 0) { | |
// 0 is PERMISSION_ALLOWED | |
var notification = window.webkitNotifications.createNotification( | |
'http://i.stack.imgur.com/dmHl0.png', | |
'Chrome notification!', | |
'Here is the notification text' | |
); | |
notification.onclick = function () { | |
window.open("http://stackoverflow.com/a/13328397/1269037"); | |
notification.close(); | |
} | |
notification.show(); | |
} else { | |
window.webkitNotifications.requestPermission(); | |
} | |
} | |
</script> | |
<div style="width: 300px; height: 300px; background: yellow" onclick="notify()"> | |
Cick here to notify | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment