Where is the documentation for the chrome extension API tab method, "getSelected"?

769 views Asked by At

So I'm creating my first chrome extension and was extremely confused for a while as I could not figure out how to grab the url of the currently open tab, until some research pointed me in the direction of chrome.tabs.getSelected(). The problem is, I cannot find anything in the API docs on this method. I've even found links to where it's supposed to be (http://code.google.com/chrome/extensions/tabs.html#method-getSelected) but it's not there. Am I missing something? Is this method deprecated and supposed to be replaced with something else?

3

There are 3 answers

0
abraham On BEST ANSWER

chrome.tabs.getSelected was removed in release 16.

The methods getAllInWindow() and getSelected() have been deprecated. To get details about all tabs in the specified window, use chrome.tabs.query() with the argument {'windowId': windowID}. To get the tab that is selected in the specified window, use chrome.tabs.query() with the argument {'active': true}.

The documentation for chrome.tabs.query is here.

0
Sungguk Lim On

you should switch

chrome.tabs.getSelected(null, function() {...} );

with

chrome.tabs.query({active: true}, function() {...} );
0
Skalár Wag On

you should switch

chrome.tabs.getSelected(null, function(tab){...});

with

chrome.tabs.query({currentWindow:true,active:true}, function(tabs){tab=tabs[0];...});