2

我开发了一个Chrome 扩展程序,它在 Chrome 39 中运行良好,但在Ubuntu 14.04(64 位)上的 Opera developer 24 中出现错误。

响应 tabs.query 时出错:TypeError: Cannot read property 'id' of undefined at HTMLLIElement.click

所以我chrome.tabs.query在两个浏览器控制台上进行了测试:

chrome.tabs.query(
  { active: true, highlighted: true, currentWindow: true }, 
  function(thisTab) {
    console.log(thisTab);
  }
);

在 Chrome 中,它返回一个完整的Tab对象。

但在 Opera 中,它返回一个空白数组[]

截图

为什么会这样?

4

1 回答 1

3

似乎 Opera 不包含高亮标签的概念,这在 Chrome 中已经很模糊了。

无论如何,您的查询过多:在 Chrome 中,活动选项卡不能不突出显示。

因此,对于同时适用于两者的查询,请使用{active: true, currentWindow: true}.

于 2014-12-04T08:05:37.210 回答