Chrome插件:弹出桌面通知

时间:2024-03-10 07:03:25
if (window.Notification) {
        var popNotice = function() {
            if (Notification.permission == "granted") {
                var notification = new Notification("信息"
                    , {
                     body:"你好",
                   // icon:图片地址,
                   
                       }
                );
                notification.onclick = function() {
                    notification.close();    
                };
            }    
        };
            if (Notification.permission == "granted") {
                popNotice();
            } else if (Notification.permission != "denied") {
                Notification.requestPermission(function (permission) {
                  popNotice();
                });
            }
    } else {
        alert(\'浏览器不支持Notification\');