简体   繁体   English

如何使用 Firefox WebExtensions API 将选项卡置于最前面

[英]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).我正在开发Firefox WebExtensionFirefox WebExtension的新技术,以使 Chrome 扩展程序与 Firefox 兼容)。

Now I need to bring a specific tab to front by tab id.现在我需要通过选项卡 id 将特定选项卡放在前面。

I tried chrome.tabs.update(this.id, { selected: true }, callback);我试过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).这适用于 Chrome,但 Firefox 不支持selected属性(也不支持highlighted )。

Does anybody know how to do this?有人知道怎么做这个吗?

Document of chrome.tabs.update . chrome.tabs.update 文档 No other property seems the one I need.似乎没有其他财产是我需要的。

You are looking for the active property for tabs.update() .您正在寻找tabs.update()active属性 This also works in Chrome.这也适用于 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.我对来自浏览器操作弹出窗口的回答:打开一个新选项卡并填充输入字段显示在扩展程序中使用chrome.tabs.update(tab.id,{active:true})激活已由扩展程序打开的选项卡,而没有使其成为打开选项卡时的活动选项卡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM