rugk
rugk

Reputation: 5493

Can an extension close it's own popup opened by a browserAction or pageAction?

I know there is the openPopup API to open a browserAction popup.

However, when it is open and a user e.g. selected something, can I somehow close it?

The same applies for a pageAction.


Cross-posted at Mozilla Discourse.

Upvotes: 2

Views: 766

Answers (1)

rugk
rugk

Reputation: 5493

Actually, as for any other website a simple window.close(); works totally fine!

This was too simple.

Only tested in Firefox though.

Edit: As @juraj.masiar made me aware this won't work for Firefox for Android though:

You will have to use browser.tabs.getCurrent().then(tab => browser.tabs.remove(tab.id)). Plus you need to detect that you are running Android using browser.runtime.getPlatformInfo() function.

Upvotes: 3

Related Questions