How I can close all tabs in Google Chrome window using API
问题 I need close all tabs in Chrome window via my extension. What is the best practice now? How would you have done? 回答1: In your background page, use chrome.tabs.query(...) to get all tabs, then call chrome.tabs.remove(...) to close that, code will look like: chrome.tabs.query({}, function (tabs) { for (var i = 0; i < tabs.length; i++) { chrome.tabs.remove(tabs[i].id); } }); 回答2: You can only close windows/tabs that you create yourself. That is, you cannot programmatically close a window/tab