Javascript(Chrome 扩展)notification.cancel() 行为不当
这是我的简单功能:
if (req.status == 200)
{
var notification = webkitNotifications.createNotification(
'icon.png', // icon url - can be relative
'Done!', // notification title
'Just updated and saved the latest blocklist'
);
notification.show();
new_version_show_window();
setTimeout( function () { notification.cancel(); }, 4000);
}
基本上它是一个 AJAX 调用,一旦下载列表,它就会显示通知,
如果是新安装或升级,它会调用“new_version_show_window()”,然后它应该关闭通知...但它不会,有时会,有时不会:(
This is my simple function:
if (req.status == 200)
{
var notification = webkitNotifications.createNotification(
'icon.png', // icon url - can be relative
'Done!', // notification title
'Just updated and saved the latest blocklist'
);
notification.show();
new_version_show_window();
setTimeout( function () { notification.cancel(); }, 4000);
}
Basically its an AJAX call, once it downloads the list it shows the notification,
if its a new install or upgrade it calls ´new_version_show_window()´ and then it should close the notification... but it does not, sometimes it does, sometimes it does not :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也无法使
cancel()
正常工作。作为解决方法,我使用以下 JavaScript 创建了一个 html 通知:In couldn't make
cancel()
work properly either. For a workaround I created an html notification with the following javascript: