Reputation: 41
I want op the options page in a webextension from a link in the browseraction popup.
I have created the file background.js (and included it in the manifest) with this content:
function openOptions() {
browser.runtime.openOptionsPage();
};
//openOptions()
If I call the function directly in the backgroud script it works and the options page opens when the add-on is loaded.
But how do I call this function from a link in the browseraction popup?
In my popup.html I have tried:
<a onclick="openOptions()">options</a>
That does not work.
I thought that backgroud scripts where available.
Upvotes: 0
Views: 87
Reputation: 7721
You can, but don't need to go all the way to the background page.
in the popup.html
<a id="options">options</a>
In the popup.js
document.querySelector('#options').addEventListener('click', () => browser.runtime.openOptionsPage());
Upvotes: 1