I'm working on a slideshow extension for Google Chrome. I've created the code that fetches the right URLs and opens them in one tab each. Now I'm looking for a function in the Chrome extension API that will allow me to switch tabs programmatically, but I can't find one? Is there one and if not, what are my options?
Asked
Active
Viewed 3,532 times
7
-
You want to cycle through the tabs or switch tabs? I don't understand this question. The title is similar to ["Chrome-Extension: iterate through all tabs?"](http://stackoverflow.com/questions/5409242) but the question body makes it sound totally different `\-:` – hippietrail Dec 23 '12 at 07:15
2 Answers
16
Are you looking for the Tabs API? The update()
method allows you to select a tab like this:
chrome.tabs.update(tabId, {selected: true});

Digital Plane
- 37,354
- 7
- 57
- 59
-
That's exactly the API I was looking at - and working with to create the new tabas - but I misread, I thought it could only update the URL. Thank you. – C. E. Sep 16 '11 at 20:48
-
4I believe that the property is now called `active`, not `selected`, although this still works for backwards compatibility reasons. – LukeGT Oct 24 '12 at 06:25
2
The value selected
has been deprecated. Use highlighted
instead:
chrome.tabs.update(tabId, {highlighted: true});

iDevGeek
- 464
- 5
- 4