浏览器推通知给桌面

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

 

posted @ 2015-11-10 10:11  李照耀  阅读(269)  评论(0编辑  收藏  举报