2016-08-01 12 views
1

ユーザーがアイコンを押すと変数に現在の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に指定するにはどうすればよいですか?ありがとうございました。

答えて

0

あなたは

chrome.tabs.update(activeTab, { 
    active: true, 
    url: "https://mywebsite.com/" + myarray[count] 
}, function(tab){});` 

tabIdupdatePropertiesを使うべきでは二つの異なるパラメータです。

+0

優れています。ありがとうございました。私はそれが許せば私は承認するでしょう。 – Katie

+0

@Katie、申し訳ありませんが、あなたの要件についてはあまり明確ではありません。あなたは "' 'tabs.update'は現在のタブから私を引き離してくれないと呼びますか? –

+0

何も問題は解決しませんでした。私は「アクティブ:真」のことについて混乱しました。 – Katie

関連する問題