1
我有一个Chrome扩展,当用户按下图标时,它将当前的tab.id
存储在变量中,然后在2分钟后运行chrome.tabs.executeScript
函数。据我所知,我的代码应该工作,但我得到的错误:Chrome扩展 - 使用tabId更新某个标签
Uncaught Error: Invalid value for argument 1. Property 'tabId': Unexpected property
From the chrome developer site
更新
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
哪个标签要更新?谢谢。
非常好,那有效。谢谢。我会批准,当它让我。 – Katie
@凯蒂,对不起,但没有太多清楚你的要求。你是什么意思“'tabs.update'被称为它不会带我离开我目前的标签”? –
没什么,我解决了这个问题。我对“积极:真实”的东西感到困惑。 – Katie