Search code examples
javascriptfirefoxfirefox-addonfirefox-addon-webextensions

How to bring tab to front using Firefox WebExtensions API


I'm developing a Firefox WebExtension (A new technology of Firefox Add-on, in order to make Chrome extensions compatible with Firefox).

Now I need to bring a specific tab to front by tab id.

I tried chrome.tabs.update(this.id, { selected: true }, callback);. This works for Chrome, but Firefox doesn't support selected property (And doesn't support highlighted either).

Does anybody know how to do this?

Document of chrome.tabs.update. No other property seems the one I need.


Solution

  • You are looking for the active property for tabs.update(). This also works in Chrome.

    You should use:

    chrome.tabs.update(this.id, { active: true }, callback);
    

    My answer to From a browser action popup: open a new tab and fill input fields shows using chrome.tabs.update(tab.id,{active:true}) in an extension to activate a tab which had been opened by the extension without making it the active tab at the time the tab was opened.