1
我需要訪問我的Chrome擴展創建的窗口的tab.Id。將變量傳遞給chrome.tabs.onUpdated.addListener() - Chrome擴展
這裏是我用來創建一個窗口中的代碼:
chrome.windows.create({
url: fullUrl,
width: w,
height: h,
type: 'normal'
}, function() {
chrome.windows.getCurrent(function(window) {
chrome.tabs.getSelected(window.id,
function (response){
var ourWindow = response.id
alert('created a window with a tab id of: ' + ourWindow);
});
});
});
在哪裏,我想能夠訪問「ourWindow」變量,我們之前設置的密碼:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.status == "loading") {
if(tabId == ourWindow) {
alert('Holy smokes, this is the window we created!');
}
}
});
我似乎無法訪問該變量,因爲它是在onUpdated.addListener之外創建的。有任何想法嗎?
這個做到了SERG,謝謝! –