Last active
December 18, 2015 23:39
-
-
Save I3rixon/5863370 to your computer and use it in GitHub Desktop.
html5 notify [Firefox 22+]
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 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