Chrome扩展-使用tabId更新某些选项卡
Chrome extension - update certain tab using tabId
我有一个chrome扩展,当用户按下图标时,它会将当前tab.id
存储在变量中,然后在2分钟后运行chrome.tabs.executeScript
函数。据我所知,我的代码应该可以工作,但我得到了一个错误:
Uncaught Error: Invalid value for argument 1. Property 'tabId': Unexpected property
来自铬显影剂网站
更新
chrome.tabs.update(integer tabId, object updateProperties, function callback)
修改选项卡的属性。
这是我到目前为止的代码:
//Up here is the logic for handling the icon press
chrome.tabs.query({ active: true, currentWindow: true }, function(arrayOfTabs) {
var activeTab = arrayOfTabs[0].id; //this is the active tab id.
setInterval(function() { //Interval for every 2 minutes
chrome.tabs.update({
tabId: activeTab, //this is where I get an error... What's wrong with this?
active: true,
url: "https://mywebsite.com/" + myarray[count]
}, function(tab) {
chrome.tabs.executeScript(tab.id, {
file: "function/jquery.min.js",
runAt: "document_end"
});
chrome.tabs.executeScript(tab.id, {
file: "function/code.js",
runAt: "document_end"
});
})
count++;
}, timer);
});
关于我的代码出了什么问题,有什么想法吗?我试过tabId: activeTab
和activeTab
,但总是出错。如何向tabs.update
指定要更新的选项卡?非常感谢。
您应该使用
chrome.tabs.update(activeTab, {
active: true,
url: "https://mywebsite.com/" + myarray[count]
}, function(tab){});`
CCD_ 8和CCD_。
相关文章:
- 从选项页面更新chrome扩展清单权限
- 在日期更改后更新Angular UI引导程序日期选择器选项
- 更新:仅根据单选按钮和所选选项选择特定项目
- AngularJS模型在手动更改选项后不会更新
- 当html选择/选项发生更改时,需要更新输入字段
- 如何从Angular.JS中的子页面更新选项卡视图
- 更新选项卡开关/更改上的chrome扩展图标
- 在 magento 中使用多个价格,但在更改自定义选项时不会更新
- 在 ExtJS 中更新选项卡开关上的网格面板
- 如何使用原始选择选项的值更新引导选择的数据原始索引
- 自定义选项更新 Magento 产品图像
- 如何做一个HTML选择表单,其中所选选项更新JSON值
- AngularJS如何使用ng选项更新选择框中的嵌套模型
- 根据选择选项更新多个单选按钮
- 使用select选项更新动态生成的两个框的价格
- 根据数据库中另一个下拉菜单中选择的选项更新一个下拉菜单
- 多次选择选项更新一次按钮按下
- 如何在d3.js中更改json文件并使用选择选项更新图表
- 无法按下拉选项更新同一页面
- 基于selectlist选项更新输入字段