HTML5的桌面提醒消息

Posted on 2015-11-12 17:07  斯是陋室,惟吾德馨  阅读(166)  评论(0编辑  收藏  举报
function fnShow() {   
       var date = new Date();   
       var time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();   
       Notification.requestPermission(function (perm) {   
           if (perm == "granted") {   
               var notification = new Notification("现在时间:", {   
                   dir: "auto",   
                   lang: "hi",   
                   tag: "testTag",   
                   icon: "img/QR.png",   
                   body:  time   
               });   
           }   
       })   
   }
<input type="button" value="桌面提醒显示时间" onClick="fnShow();">
注意,需要在服务器端运行