Skip to content

Instantly share code, notes, and snippets.

@paulgibbs
Created June 12, 2012 14:04
Show Gist options
  • Save paulgibbs/2917729 to your computer and use it in GitHub Desktop.
Save paulgibbs/2917729 to your computer and use it in GitHub Desktop.
OS X Notification Center in Safari 5.2

OS X Notification Center in Safari 5.2

OS X Mountain Lion adds Notification Center for managing alerts. Just like growl, but better.

Safari 5.2 exposes HTML5 notifications API to sites. Every site need to have permission for showing notifications.

Specification is very new and completely different from older version Chrome has. Developer doesn't have to watch for complicated NotificationCenter.

The syntax is very simple:

var notification = new Notification('Title', 'text');
// The event part is optional.
notification.addEventListener('show', function() {
  setTimeout(function() {
    notification.cancel();
  }, 2000);
}, true);
notification.show();

Screenshots:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment