Created
April 27, 2017 13:32
-
-
Save arielsvn/37f70caecac73902dfe4f2e989620a2a to your computer and use it in GitHub Desktop.
// source https://jsbin.com/qoharusepi
This file contains 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
<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> |
This file contains 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
// 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