<!DOCTYPE HTML>
<html>
<body>
Notification
</body>
<script type=
"text/javascript">
checkNotification();
function checkNotification(){
if (!(
'Notification' in window)) {
alert('This browser does not support desktop notification');
}
// check whether notification permissions have alredy been granted
else if (Notification.permission ===
'granted') {
// If it‘s okay let‘s create a notification
new Notification(
'Granted!');
}
// Otherwise, ask the user for permission
else if (Notification.permission !==
'denied') {
Notification.requestPermission(function (permission) {
// If the user accepts, let‘s create a notification
if (permission ===
'granted') {
new Notification(
'Request granted!');
}
});
}
}
</script>
</html>
转载于:https://www.cnblogs.com/lizhaoyao/p/4952043.html
相关资源:跨浏览器的桌面通知插件Push.js.zip