如何强制chrome.tabs.query返回一个值?

时间:2015-11-17 10:56:41

标签: javascript google-chrome-extension google-chrome-app

是否可以从chrome.tabs.query(...)或chrome.tabs.getSelected(...)获取值 因为现在是

chrome.tabs.query({active:true}, function(tabs){
    var indx = tabs[0].index;
    chrome.tabs.create({url: getPageUrl(), index : indx });
});

但我需要类似于

function getCurrentIndex(){
    return chrome.tabs.query({active:true}, function(tabs){
        var indx = tabs[0].index;
        return indx;
    })
}
chrome.tabs.create({url: getPageUrl(), index : getCurrentIndex() });

0 个答案:

没有答案