Chandrakant Thakkar Chandrakant Thakkar - 1 year ago 76
Javascript Question

Firefox mozilla web extensions : How to know when a tab has finished loading, from the background page

I want to perform action after Page loaded through web extension in mozilla ,

I have tried same method available in chrome as bellow

browser.tabs.onUpdated.addListener(function (tabId , info) {
if (info.status === 'complete') {
// your code ...
}
});


But it is not working well I am not getting "complete" status in some of cases,sometimes multiple iframes are there in web page.

So is there any solution to check weather page loading completed?

Answer Source

You can use following way to solve your problem,

      browser.tabs.onUpdated.addListener(function(tabId, changeInfo,tab) {
       if (tab.status == "complete" && tab.active) { 
      //Perform you task after page loaded    completely 
   }
  }

This is tested way by me in mozilla web extension Thanks

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download