Reputation: 800
I know we can close a popup using window.close()
from popup.
But is there any way to close the popup from the background page in a Chrome extension?
Upvotes: 1
Views: 941
Reputation: 77482
It's possible with chrome.extension.getViews
:
var windows = chrome.extension.getViews({type: "popup"});
if (windows.length) {
windows[0].close(); // Normally, there shouldn't be more than 1 popup
} else {
console.log("There was no popup to close");
}
Upvotes: 3