Skip to content

Instantly share code, notes, and snippets.

@arielsvn
Created April 27, 2017 13:32
Show Gist options
  • Save arielsvn/37f70caecac73902dfe4f2e989620a2a to your computer and use it in GitHub Desktop.
Save arielsvn/37f70caecac73902dfe4f2e989620a2a to your computer and use it in GitHub Desktop.
<button onclick="notifyMe()">
Notify me!
</button>
<script id="jsbin-javascript">
// request permission on page load
document.addEventListener('DOMContentLoaded', function () {
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Nike Shoes', {
icon: 'http://www.superoffers.com/assets/base-s852f242db1-782fe0ddc0dd069e56853a81d7cd9a8e976e14cdb2234b2a55c82ac67c084ec0.png',
body: "Check out our latest offers on Nike Shoes!",
});
notification.onclick = function () {
window.open("http://superoffers.com");
};
}
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">// request permission on page load
document.addEventListener('DOMContentLoaded', function () {
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Nike Shoes', {
icon: 'http://www.superoffers.com/assets/base-s852f242db1-782fe0ddc0dd069e56853a81d7cd9a8e976e14cdb2234b2a55c82ac67c084ec0.png',
body: "Check out our latest offers on Nike Shoes!",
});
notification.onclick = function () {
window.open("http://superoffers.com");
};
}
}
</script>
// request permission on page load
document.addEventListener('DOMContentLoaded', function () {
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Nike Shoes', {
icon: 'http://www.superoffers.com/assets/base-s852f242db1-782fe0ddc0dd069e56853a81d7cd9a8e976e14cdb2234b2a55c82ac67c084ec0.png',
body: "Check out our latest offers on Nike Shoes!",
});
notification.onclick = function () {
window.open("http://superoffers.com");
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment