码迷,mamicode.com
首页 > 其他好文 > 详细

浏览器推通知给桌面

时间:2015-11-10 10:39:11      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

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

 

浏览器推通知给桌面

标签:

原文地址:http://www.cnblogs.com/lizhaoyao/p/4952043.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!