web Notification api生成多个Notification,有办法获取所有Notification对象吗?var n = new Notification(o.user.userid);
n.onshow = function () {
setTimeout(n.close.bind(n), 5000);
}new了n个,然后不想设置定时关闭,想一次性关闭所有Notification,有办法获取所有Notification对象吗?
1 回答
富国沪深
TA贡献1790条经验 获得超9个赞
定义一个数组,每次生成的时候把Notification对象加进去不就行了,期待大家更好地解决办法
if (window.Notification && Notification.permission !== "denied") { Notification.requestPermission(function (status) { var n = new Notification(title, { body: content, icon: icon }); NotificationItems.push(n); }); }
操作的时候
while (NotificationItems.length > 0) { NotificationItems[0].close(); NotificationItems.shift(); }
添加回答
举报
0/150
提交
取消