tabsgoogle-chrome-extensionbrowser-tab

Chrome Extension: In Tabs doc don't exist this "chrome.tabs.getSelected" but I see aniway in examples


as title I can't able find this method into the Api -> Tabs... Way and where? Thanks'


Solution

  • It was deprecated in Chrome 16. The correct way is to use chrome.tabs.query with active:true and lastFocusedWindow: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
        });
    });