admin管理员组文章数量:1301494
I am trying to grab all tabs of the current window and loop through them.
currently using code:
chrome.tabs.query({currentWindow: true}, function(result) {
result.forEach(function(tab) {
do stuff here;
});
});
I have permissions for 'tabs' in the manifest.
It is throwing the error: "Error: Invocation of form tabs.query(object) doesn't match definition tabs.query(object queryInfo, function callback) at..."
I am confused as I clearly have the object and a callback function. I also see elsewhere that it can be done with a promise instead as:
var query = chrome.tabs.query({currentWindow: true});
query.then(function(tabs) {
tabs.forEach(function(tab) {
do stuff here;
});
});
But this throws the same error. Any ideas?
I am trying to grab all tabs of the current window and loop through them.
currently using code:
chrome.tabs.query({currentWindow: true}, function(result) {
result.forEach(function(tab) {
do stuff here;
});
});
I have permissions for 'tabs' in the manifest.
It is throwing the error: "Error: Invocation of form tabs.query(object) doesn't match definition tabs.query(object queryInfo, function callback) at..."
I am confused as I clearly have the object and a callback function. I also see elsewhere that it can be done with a promise instead as:
var query = chrome.tabs.query({currentWindow: true});
query.then(function(tabs) {
tabs.forEach(function(tab) {
do stuff here;
});
});
But this throws the same error. Any ideas?
Share asked Aug 30, 2017 at 10:09 Stephen KeetonStephen Keeton 411 silver badge2 bronze badges1 Answer
Reset to default 9Promise-based approach is only valid in Firefox when using browser.*
namespace instead of chrome.*
Chrome does not natively provide Promises for its API, though Mozilla has a polyfill if you prefer that.
Your first snippet is correct and will not throw this error. Make sure you check all invocations of tabs.query
and properly reload the extension for your changes to apply.
本文标签: javascriptchrometabsquery(object) doesn39t match definitionStack Overflow
版权声明:本文标题:javascript - chrome.tabs.query(object) doesn't match definition - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741667516a2391400.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论