我正在为我的应用程序使用WebKit Notifications.假如我使用此代码:
var n = window.webkitNotifications.createNotification(
'icon.png',
'New Comment',
'Praveen commented on your post!'
);
n.onclick = function(x) { window.focus(); this.cancel(); };
n.show();
Run Code Online (Sandbox Code Playgroud)
PS 1:前五行实际上是一行.为了便于阅读,我已经发布了这种方式.
PS 2:有关完整代码,请参阅:无法使用Google Chrome显示桌面通知.
我的问题是,如果我打开了多个标签怎么办?
假设当我的应用程序上出现新评论时,这会被解雇.如果我打开多个标签怎么办?这会产生很多通知吗?说,我10 - 15打开了标签,我收到了两个通知.将生成多少通知,20 - 30?
如果是这种情况,如何防止每个打开的选项卡多次生成单个通知?
html5 notifications webkit google-chrome html5-notifications