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

3

17

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.

Knothole answered 10/8, 2014 at 5:52 Comment(0)
S
30

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

var updateProperties = { 'active': true };
chrome.tabs.update(tabId, updateProperties, (tab) => { });
Schopenhauerism answered 10/8, 2014 at 7:58 Comment(2)
And for V3 ? :)Cashmere
V3 is a change to the format of the manifest file format. The general API version is not changing.Schopenhauerism
A
4

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() {});
});
Assegai answered 31/5, 2018 at 11:55 Comment(3)
This is more correct because this method seems to be designed for tab (or tab group) focusing.Petasus
@Petasus that's not true. Multiple tabs can be highlighted at once by holding shift. When you "highlight" a tab, "activating" is just a side effect. You can only have one active tab per window but multiple highlighted tabs.Olives
Would it be correct to say that highlighting is a feature meant for grouping tabs for bulk operations whereas the property of being active is the tab which is currently in view in the browser window and accepting keyboard input?Blavatsky
N
0

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

Navar answered 24/6, 2024 at 10:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.