In my chrome extension app inside the background script, I am trying to implement this code, here is my code:
function foo(title, message, timeout) {
chrome.notifications.create({
type: 'progress',
iconUrl: 'img/GS icon.png',
title: title,
message: message || '',
progress: 0
}, function(id) {
// Automatically close the notification in 4 seconds by default
var progress = 0;
var interval = setInterval(function() {
if (++progress <= 100) {
chrome.notifications.update(id, {progress: progress}, function(updated) {
if (!updated) {
// the notification was closed
clearInterval(interval);
}
});
} else {
chrome.notifications.clear(id);
clearInterval(interval);
}
}, (timeout || 4000) / 100);
});
};
window.onload=function(){
foo('ttttitle','messsageee',10000);
}
but it always stays on 1% and doesnt move:
can not find the problem.
manifest.json:
{
"background": {
"scripts": ["js/background.js"],
"persistent": false
},
...
}