浏览器推通知给桌面

<!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