Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Firefox mozilla web extensions:如何从后台页面知道选项卡何时完成加载_Javascript_Google Chrome Extension_Mozilla_Firefox Addon Webextensions - Fatal编程技术网

Javascript Firefox mozilla web extensions:如何从后台页面知道选项卡何时完成加载

Javascript Firefox mozilla web extensions:如何从后台页面知道选项卡何时完成加载,javascript,google-chrome-extension,mozilla,firefox-addon-webextensions,Javascript,Google Chrome Extension,Mozilla,Firefox Addon Webextensions,我想在mozilla中通过web扩展加载页面后执行操作 我已经尝试了同样的方法在铬作为贝娄可用 browser.tabs.onUpdated.addListener(function (tabId , info) { if (info.status === 'complete') { // your code ... } }); 但它并没有很好地工作,在某些情况下,我并没有获得“完整”状态,有时网页中有多个iframe 那么,有没有办法检查天气页面加载是否完成?您可以使用以

我想在mozilla中通过web扩展加载页面后执行操作

我已经尝试了同样的方法在铬作为贝娄可用

 browser.tabs.onUpdated.addListener(function (tabId , info) {
   if (info.status === 'complete') {
   // your code ...
   }
});
但它并没有很好地工作,在某些情况下,我并没有获得“完整”状态,有时网页中有多个iframe


那么,有没有办法检查天气页面加载是否完成?

您可以使用以下代码来解决问题:

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

我已经尝试了@wOxxOm在评论中向我建议的一种方法,而且效果也不错:

browser.webNavigation.onCompleted.addListener(function(details) {
    if (details.frameId == 0) {
        // Here you can perform tasks after page load completed
    }
});

我猜webNavigation.onCompleted和frameId==0