Skip to content

Instantly share code, notes, and snippets.

@onerinas
Created January 12, 2015 06:04
Show Gist options
  • Save onerinas/c5c38f8bf2342482d775 to your computer and use it in GitHub Desktop.
Save onerinas/c5c38f8bf2342482d775 to your computer and use it in GitHub Desktop.
<button onclick="notifyMe()">
Notify me!
</button>
<script id="jsbin-javascript">
function notifyMe() {
if (!Notification) {
alert('Notifications are supported in modern versions of Chrome, Firefox, Opera and Firefox.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "Hey there! You've been notified!",
});
notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
};
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">function notifyMe() {
if (!Notification) {
alert('Notifications are supported in modern versions of Chrome, Firefox, Opera and Firefox.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "Hey there! You've been notified!",
});
notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
};
}
</script>
function notifyMe() {
if (!Notification) {
alert('Notifications are supported in modern versions of Chrome, Firefox, Opera and Firefox.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "Hey there! You've been notified!",
});
notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment