admin管理员组文章数量:1399974
I am new to Chrome extension developing. As far as I know, chrome.tabs.query only works in background.js, and I was trying to use the code below to check out the information returned. However, the result only returns to the background page console, and it only gives me the information of "chrome://extensions/" page.
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
console.log("tab ID:");
console.log(tabs);
});
How can I get the information of all/any of the tabs that is opening in the current window?
Thanks in advance!
I am new to Chrome extension developing. As far as I know, chrome.tabs.query only works in background.js, and I was trying to use the code below to check out the information returned. However, the result only returns to the background page console, and it only gives me the information of "chrome://extensions/" page.
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
console.log("tab ID:");
console.log(tabs);
});
How can I get the information of all/any of the tabs that is opening in the current window?
Thanks in advance!
Share Improve this question asked Jul 3, 2016 at 2:34 Adam LiuAdam Liu 1,34614 silver badges17 bronze badges1 Answer
Reset to default 6You just need to remove active
key from query method, because it returns the current tab you are staying on.
So all the tabs of the current window will be returned by the following:
chrome.tabs.query({currentWindow: true}, function(tabs) {
tabs.forEach(function(tab) {
console.log('Tab ID: ', tab.id);
});
});
for more details you could take a look at query
method docs here
本文标签: javascriptHow can chrometabsquery show information of all tabsStack Overflow
版权声明:本文标题:javascript - How can chrome.tabs.query show information of all tabs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744230513a2596307.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论