问题描述:

I have this notification, but it only shows for ~5 seconds. I would like it to stay for longer/or make it stay until I click on it.

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();

}

});

Suggestions on how to do this please?

网友答案:

I don't think it's possible using the webkitNotifications API.

You could use the Rich Notification API from chrome.experimental.notification. They're not a lot of information on this API yet, but Google released a short video containing a couple of examples, which can be seen here: http://www.youtube.com/watch?v=g8fJWB2-pYk.

However note that if you decide to use the APIs from chrome.experimental then you cannot release your app on the Chrome Web Store. More info on the experimental APIs can be found at http://developer.chrome.com/extensions/experimental.html

网友答案:

also you can do this before call the function "show()":

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

I think you know how to work with it.

相关阅读:
Top