if (window.Notification) {
console.log(Notification.permission);
if (Notification.permission === 'granted') {
var notification = new Notification('标题', { body: "内容可以自己随便定义" });
notification.onclick = function (e) {
alert("点击了我")//可以点击打开一个网址
}
} else {
console.log('sss');
Notification.requestPermission();//设置允许通知
}
}
标签:提醒,console,log,permission,Notification,点击,消息,notification
From: https://www.cnblogs.com/Sultan-ST/p/16809048.html