Skip to content

Instantly share code, notes, and snippets.

@oem
Created October 21, 2011 09:22
Show Gist options
  • Select an option

  • Save oem/1303434 to your computer and use it in GitHub Desktop.

Select an option

Save oem/1303434 to your computer and use it in GitHub Desktop.
HTML5 desktop notifications - a simple example
(function ($) {
var notify, initialize, requestPermission;
notify = function () {
var notification;
if (window.webkitNotifications) {
if (window.webkitNotifications.checkPermission() > 0) {
window.webkitNotifications.requestPermission(this);
}
notification = window.webkitNotifications.createNotification(
"coyote.gif",
"Notification title",
"Notification body"
);
notification.show();
setTimeout(function () {
notification.cancel();
}, 5000);
}
};
initialize = function () {
$("a.notify").click(notify);
};
$(function () {
initialize();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment