【问题标题】:Firefox Addon why readystate for tab gives undefinedFirefox插件为什么readystate for tab给出未定义
【发布时间】:2015-03-27 15:22:55
【问题描述】:

我尝试在打开 4 个网站时等待,直到加载完成然后获取它们的标题。为此,我使用了readystate,它没有等到加载完成并将Connecting 作为标题。当我签入控制台时,就绪状态给出未定义。下面是我的代码。

我使用的sdk是1.17,ff是36.0.4。

var tabs = require("sdk/tabs");
tabs.open("https://developer.mozilla.org");
tabs.open("http://www.nytimes.com/");
tabs.open("http://en.wikipedia.org/wiki/Main_Page");
tabs.open("https://www.google.co.in");

for (let tab of tabs)
{
  console.log(tab.title + tab.readystate);
};

【问题讨论】:

    标签: javascript firefox-addon readystate


    【解决方案1】:

    知道了!最后我通过替换使其工作

    for (let tab of tabs)
    {
    console.log(tab.title + tab.readystate);
    };
    

    tabs.on('ready', function(tab) {
     console.log('tab is loaded', tab.title, tab.url, tab.readyState);
    });
    

    作为https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/tabs#activate_2中关于'readystate'的解释

    感谢所有在此期间尝试解决此问题的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 2016-11-30
      • 2013-12-03
      • 2021-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多