10

I am making a chrome extension and my problem is that chrome.tabs.onUpdated.addListener() is being called multiple times.

My code is like this

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if(changeInfo.status == 'complete' && tab.status == 'complete' && tab.url != undefined){ doSomething } }); 

This is related to Chrome Issue 162543 and it appears as fixed but I still have this problem.

2
  • Is the event listener getting run multiple times or are there multiple events triggering? Commented Dec 31, 2014 at 4:07
  • 1
    Can you post your manifest.json file? If you have "persistent": false in your background entry, you can get multiple calls on the onUpdated event. Commented Feb 24, 2015 at 20:00

1 Answer 1

10

Please be aware chrome.tabs.onUpdated will also fired for iframes, if a page contains many iframes, each completed iframe will trigger the event though you have checked changeInfo.status.

To solve this issue, you could take a look at my answer in this post Chrome extension - page update twice then removed on YouTube, and use chrome.webNavigation.onCompleted or chrome.webNavigation.onHistoryStateUpdated, which depends on your testing sites.

Sign up to request clarification or add additional context in comments.

Comments