Search code examples
jquerygoogle-chromegoogle-chrome-extension

chrome extension icon is not changing


I have developed a simple Chrome Extension for changing the extension icon every 300 milliseconds. But my code is not working. Below is my code:

setTimeout(updateIcon, 300);
var min = 1;
var max = 5;
var current = min;

function updateIcon() {
  chrome.browserAction.setIcon({path:"icon" + current + ".png"});
  current++;

  if (current > max)
    current = min;
}

What's wrong with the above code?


Solution

  • setTimeout will call the function just once. I think you are looking for setInterval.

    setInterval(updateIcon, 300);