var popNotice = function() {
if (Notification.permission == "granted") {
var notification = new Notification("Hi,", {
body: '可以加你为好友吗?',
icon: '/static/cute.gif'
});
notification.onclick = function() {
alert('***已于' + new Date().toTimeString().split(' ')[0] + '加你为好友!');
notification.close();
};
}
};
if (window.Notification) {
if (Notification.permission == "granted") {
popNotice();
}else if( Notification.permission != "denied"){
Notification.requestPermission(function (permission) {
popNotice();
});
}
} else {
alert('浏览器不支持Notification');
}
window.Notification实现桌面通知
最新推荐文章于 2024-06-28 14:42:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)