分享

Chrome的桌面通知

 dlshanghai 2014-04-17
 <!DOCTYPE html>
 <html>
 <head>
<title>Google 桌面通知</title>
 <meta name="generator" content="editplus" />
 <meta name="author" content="" />
 <meta name="keywords" content="" />
<meta name="description" content="" />
 <meta http-equiv='content-type' content='text/html; charset=utf-8' />
 </head>
 <body>
  
 <button id='btn' >显示桌面通知</button> 
  
 <script type='text/javascript'>
  
 document.querySelector("#btn").addEventListener('click', notify, false);
  
function notify() {
     if (window.webkitNotifications) {
         if (window.webkitNotifications.checkPermission() == 0) {
             var pic='r_'+(Math.round(Math.random()*10)%7+1)+'.jpg';
             var notification_test = window.webkitNotifications.createNotification("http://images.cnblogs.com/cnblogs_com/flyingzl/268702/"+pic, '标题', '内容'+new Date().getTime());
             notification_test.display = function() {}
             notification_test.onerror = function() {}
             notification_test.onclose = function() {}
             notification_test.onclick = function() {this.cancel();}
             
             //notification_test.replaceId = 'Meteoric';
  
             notification_test.show();
                         
          //  var tempPopup = window.webkitNotifications.createHTMLNotification(["http://www.baidu.com/", "http://www.soso.com"][Math.random() >= 0.5 ? 0 : 1]);
             //tempPopup.replaceId = "Meteoric_cry";
         //    tempPopup.show();
         } else {
             window.webkitNotifications.requestPermission(notify);
         }
     } 

 }
</script>
 </body>
 </html>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多