admin管理员组文章数量:1328972
var windows = chrome.windows.getCurrent(
function(windows){
try{
// dont really know why this is null. it should be a list of tabs.
if(windows.tabs == null)
alert(windows.type + " " + windows.id);
}
catch(e){
alert(e);
}
});
I am using this code to get all the open tabs in the current window. But the window.tabs is always null even though there are tabs open in the current window. Is there something wrong with the concept of current window. Could anyone please explain what is it that i am doing wrong. Thanks.
var windows = chrome.windows.getCurrent(
function(windows){
try{
// dont really know why this is null. it should be a list of tabs.
if(windows.tabs == null)
alert(windows.type + " " + windows.id);
}
catch(e){
alert(e);
}
});
I am using this code to get all the open tabs in the current window. But the window.tabs is always null even though there are tabs open in the current window. Is there something wrong with the concept of current window. Could anyone please explain what is it that i am doing wrong. Thanks.
Share Improve this question edited Dec 9, 2011 at 20:31 Jimmy Sawczuk 13.6k7 gold badges47 silver badges60 bronze badges asked Dec 9, 2011 at 20:15 intoTHEwildintoTHEwild 4688 silver badges24 bronze badges1 Answer
Reset to default 6Looks like the windows
object that gets passed to your callback doesn't have a tabs
field. Try this code instead:
chrome.windows.getCurrent(function(win)
{
chrome.tabs.getAllInWindow(win.id, function(tabs)
{
// Should output an array of tab objects to your dev console.
console.debug(tabs);
});
});
Also ensure that you have the tabs
permission. I also ran this on a background page, so if you're not running it on a background page, you should make sure chrome.tabs
is available in your context.
本文标签: javascriptchromewindowsgetCurrent is not returning the list of opened tabsStack Overflow
版权声明:本文标题:javascript - chrome.windows.getCurrent is not returning the list of opened tabs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742244026a2439014.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论