I am working on a chrome extension for desktop notification.Is there any way by which 开发者_运维百科I can close the desktop notification after a specified time ?
If you have a reference of the notification object, you can use notification.cancel instead:
setTimeout(function() {
notification.cancel();
}, 5000);
References:
- Chrome extension development: auto close the notification box
- http://dev.chromium.org/developers/design-documents/desktop-notifications/api-specification
You can close it by running window.close()
from notification's javascript (assuming your notification is a separated HTML file). So something like this:
setTimeout(function() {
window.close();
}, 5000);
for me this worked
setTimeout(function() {
notification.close();
}, 2000);
精彩评论