切换Google Chrome扩展程序中通知的当前标签 [英] Switch current tab from notification in Google Chrome extension

查看:141
本文介绍了切换Google Chrome扩展程序中通知的当前标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否在Chrome 标签文档中遗漏了某些内容,或者有什么方法用于扩展以更改当前活动的选项卡?

Am I missing something in the Chrome tabs documentation or is there a way for an extension to change the currently active tab?

我有一个扩展,一旦该选项卡完成加载,弹出一个通知,如果加载的选项卡不是选择,向用户提供更改以将其更改为选定。或者至少这就是我想要的。

I have an extension which, once the tab has finished loading, pops up a notification and, if the loaded tab is not selected, offers the user the change to change it to selected. Or at least that's what I want it to do.

阅读通知API 我没有看到任何提及访问 chrome.tabs.get 的方法,但有 chrome.extension.getBackgroundPage()。任何人有任何想法如何将它变成我期望做的事情?

Reading the notifications API I don't see any mention of a way of accessing chrome.tabs.get, but there is chrome.extension.getBackgroundPage(). Anyone have any idea on how to turn that into what I'm looking to do?

非常感谢提前。

推荐答案

您可以选择一个标签:

You can make a tab selected with:

chrome.tabs.update(tabId, {highlighted: true});

Chrome API可在通知html中使用,因此您可以调用任何 chrome。 * 你喜欢的方法。

Chrome API is available inside notification html, so you can call any chrome.* method you like.

这篇关于切换Google Chrome扩展程序中通知的当前标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆