html5桌面通知--notification

1
2
3
4
5
6
7
8
9
10
if (window.Notification) {
if (Notification.permission === 'granted') {
var notification = new Notification('标题', { body: "孩子你在干啥" });
notification.onclick = function (e) {
alert("哎呀,你弄疼人家了")//可以点击打开一个网址
}
} else {
Notification.requestPermission();//设置允许通知
}
}

参考链接:http://www.cnblogs.com/wuyubing/p/4608303.html
兰陵大佬(建议直接使用):https://blog.thkira.com/2016/05/notification.html