Javascript(Chrome扩展名)通知。cancel()行为不正常
这是我的简单功能:Javascript(Chrome扩展名)通知。cancel()行为不正常,javascript,notifications,google-chrome-extension,settimeout,Javascript,Notifications,Google Chrome Extension,Settimeout,这是我的简单功能: if (req.status == 200) { var notification = webkitNotifications.createNotification( 'icon.png', // icon url - can be relative 'Done!', // notification title
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\u version\u show\u window()”,然后应该关闭通知。。。但是它没有,有时有,有时没有:(In无法使
cancel()
正常工作。为了解决这个问题,我使用以下javascript创建了一个html通知:
setTimeout( function () { window.close(); }, 4000);
在中,无法使
cancel()
正常工作。为了解决此问题,我使用以下javascript创建了一个html通知:
setTimeout( function () { window.close(); }, 4000);