Skip to content

Instantly share code, notes, and snippets.

@I3rixon
Last active December 18, 2015 23:39
Show Gist options
  • Save I3rixon/5863370 to your computer and use it in GitHub Desktop.
Save I3rixon/5863370 to your computer and use it in GitHub Desktop.
html5 notify [Firefox 22+]
function desktopNotification(image, title, body, timeout) {
...
if( (navigator.userAgent.toLowerCase().match('firefox\/(.*)')[1] | 0) >= 22 ){
var notice = new Notification(title, { tag : "cryptocat", body : body, icon : image });
if (timeout > 0) {
window.setTimeout(function() {
notice.close()
}, timeout)
}
}
...
}
...
...
// Desktop notifications button.
if (!window.webkitNotifications && !Notification.permission) {
$('#notifications').remove()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment