Ric*_*ick 8

已在Chrome 16弃用.正确的方法是使用chrome.tabs.queryactive:truelastFocusedWindow:true.

// Get the current active tab in the lastly focused window
chrome.tabs.query({
    active: true,
    lastFocusedWindow: true
}, function(tabs) {
    // and use that tab to fill in out title and url
    var tab = tabs[0];
    run({
        url: tab.url,
        description: tab.title
    });
});
Run Code Online (Sandbox Code Playgroud)