yifanwu
yifanwu

Reputation: 1645

is there a way to focus on a specific tab in chrome (via plugin)

I want to be able to focus on a specific tab.

After chrome.tabs.query I get the id but how do I set focus on that tab? I don't see this option in the documentation.

Upvotes: 18

Views: 20409

Answers (3)

sarthi kalathiya
sarthi kalathiya

Reputation: 1

the easiest way to do this is with a extension of chrome "always active window"

Upvotes: 0

abraham
abraham

Reputation: 47833

You should be able to do this with chrome.tabs.update.

var updateProperties = { 'active': true };
chrome.tabs.update(tabId, updateProperties, (tab) => { });

Upvotes: 31

Aniket Thakur
Aniket Thakur

Reputation: 68915

You can also use https://developer.chrome.com/extensions/tabs#method-highlight

chrome.tabs.get(tabId, function(tab) {
  chrome.tabs.highlight({'tabs': tab.index}, function() {});
});

Upvotes: 4

Related Questions