2
在後臺腳本中,我向每個選項卡發送請求。我的問題是如何從回調函數中獲取響應的標籤?由於sendRequest是異步的,tab.id不能在callbock中使用。找出在Chrome擴展中發送響應的選項卡
for (var i = 0, tab; tab = tabs[i]; i++) {
chrome.tabs.sendRequest(tab.id, {play:0}, function(response) {
// do something here
// how do i get the tab.id from which the response come from?
});
}