chrome.tab.onactivated [英] chrome.tab.onactivated

查看:789
本文介绍了chrome.tab.onactivated的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何使用 chrome.tabs.onActivated



我想刷新点击/激活的标签,如果URL等于: www.example.com



或者如果这是错误的方法,请告诉我要使用什么。 首先,请务必在您的 manifest.json 文件中加入标签权限。然后,在后台页面脚本中使用 chrome.tabs.onActivated 。每次这个事件被调用时,你都会得到 activeInfo 包含当前活动标签ID的对象。拥有此ID,您可以获取标签并查看设置了哪个网址至。当您确定这是您正在查找的选项卡(网址匹配项)时,您可以重新加载


Can someone please show me how to use the chrome.tabs.onActivated.

I would like to refresh the tab that is clicked/activated if the url equals: www.example.com.

Or if this is the wrong method please tell me what to use.

解决方案

Firstly, be sure to put "tabs" permission in your manifest.json file. Then, use chrome.tabs.onActivated in your background page script. Each time this event will be called you will get activeInfo object containing currently active tab ID. Having this ID you can fetch the tab and see what URL is it set to. When you are certain that this is a tab you are looking for (URL matches) you can reload it.

这篇关于chrome.tab.onactivated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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