ユーザーがアイコンを押すと変数に現在の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);
});
すべてのアイデアは私のコードで間違って何に?私はactiveTab
と同様にtabId: activeTab
を試しましたが、私はエラーが発生し続けます。どのタブを更新するかをtabs.update
に指定するにはどうすればよいですか?ありがとうございました。
優れています。ありがとうございました。私はそれが許せば私は承認するでしょう。 – Katie
@Katie、申し訳ありませんが、あなたの要件についてはあまり明確ではありません。あなたは "' 'tabs.update'は現在のタブから私を引き離してくれないと呼びますか? –
何も問題は解決しませんでした。私は「アクティブ:真」のことについて混乱しました。 – Katie