如何获取浏览器中打开的标签数量和当前标签的数量?
			
			2882 次
		
3 回答
            2        
        
		
使用chrome.tabs.getAllInWindow().length然后
chrome.tabs.getCurrent(function(Tab t) {
  // current tab index
  alert(t.index);
}) 
更新
getAllInWindow自 Chrome 33 起已弃用。您应该使用querywith{windowId: chrome.windows.WINDOW_ID_CURRENT}或{currentWindow: true}.
于 2013-02-11T07:32:37.243   回答
    
    
            2        
        
		
从 Chrome 16 开始,请使用https://developer.chrome.com/extensions/tabs#method-query。
例子:
chrome.tabs.query({}, function(foundTabs) {
        var tabsCount = foundTabs.length;
        console.info("tabsCount = " + tabsCount);
    });
    于 2016-11-27T10:28:27.817   回答
    
    
            -1        
        
		
试试这个扩展:Tabs Counter。
于 2013-02-11T07:32:33.287   回答