Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何保留桌面通知?_Javascript_Google Chrome_Google Chrome Extension - Fatal编程技术网

Javascript 如何保留桌面通知?

Javascript 如何保留桌面通知?,javascript,google-chrome,google-chrome-extension,Javascript,Google Chrome,Google Chrome Extension,我收到了此通知,但仅显示约5秒钟。我想让它停留更长时间/或者让它停留到我点击它为止 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if ((String(tab.title).search("Sniped:"))==0){ var notification = webkitNotifications.createNotification( 'face.png',

我收到了此通知,但仅显示约5秒钟。我想让它停留更长时间/或者让它停留到我点击它为止

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
  if ((String(tab.title).search("Sniped:"))==0){
    var notification = webkitNotifications.createNotification(
        'face.png',
        'Sniper',
        tab.title
    );
    notification.show();
 }
}); 

请给出一些建议?

我认为使用WebKitNotificationsAPI是不可能的

您可以使用chrome.experional.Notification中的富通知API。关于这个API,他们还没有太多的信息,但是Google发布了一个包含两个示例的短视频,可以在这里看到:


但是请注意,如果您决定使用chrome.Experiative的API,则无法在chrome网络商店上发布应用程序。有关实验API的更多信息,请访问

,也可以在调用函数“show()”之前执行此操作:

我想你知道如何使用它

 notification.ondisplay = function(event) {
        setTimeout(function() {
            event.currentTarget.cancel();
        }, 10000);
    };