【发布时间】:2012-10-07 08:27:22
【问题描述】:
我正在为我的应用程序使用 WebKit 通知。说我是否正在使用此代码:
var n = window.webkitNotifications.createNotification(
'icon.png',
'New Comment',
'Praveen commented on your post!'
);
n.onclick = function(x) { window.focus(); this.cancel(); };
n.show();
PS 1:前五行实际上是一行。只是为了便于阅读,我以这种方式发布。
PS 2:完整代码请见:Unable to show Desktop Notifications using Google Chrome。
我的问题是,如果我打开了多个标签怎么办?
说当我的应用上出现新评论时,这是否会被解雇。如果我打开了多个标签怎么办?这会产生很多通知吗?比如说,我打开了10 - 15 选项卡,我收到了两个通知。将生成多少个通知,20 - 30?
如果是这样,如何防止为每个打开的标签多次生成单个通知?
【问题讨论】:
-
ddnt 甚至不知道这个功能,大声笑,去研究它!
-
试试吧,伙计。太棒了! :) 查看我的链接问题,了解我实施它的方式! :)
-
我也在寻找这个问题的答案。你有什么解决办法吗?
-
您能找到解决问题的方法吗?我现在在完全相同的地方:( 尝试了答案中的解决方案,但它在萤火虫中出现错误 -
ReferenceError: Notification is not defined [Break On This Error]var notification = new Notification('Hey!', { -
很遗憾看到这个庞大的 SO 社区中没有人知道解决方案。
标签: html google-chrome webkit notifications html5-notifications