chrome.tabs.onUpdated.addListener(。。
注意使用chrome.tabs.onUpdated.addListener需要在manifest.json声明tabs权限
permissions: [‘tabs’]
function handleUpdated(tabId, changeInfo, tabInfo) { console.log(`Updated tab: ${tabId}`); console.log("Changed attributes: ", changeInfo); console.log("New tab Info: ", tabInfo); } chrome.tabs.onUpdated.addListener(handleUpdated);
或者
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { alert(tabId); });