Chrome插件:弹出桌面通知

时间:2021-07-22 01:45:56
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');