Reputation: 679
I try to create a simple firefox web extension. As a first try i thought I want to just get some alert box when the extension button is clicked
I created this manifest.json
{
"manifest_version": 2,
"name": "FirstExt",
"version": "1.0",
"description": "first script",
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": "icons/icon-38.png",
"default_title": "My first extension"
}
}
and in background.js:
browser.browserAction.onClicked.addListener(function(){ alert("hello"); });
I tried changing it to console.log
but get no output. What am I doing wrong here?
Upvotes: 1
Views: 100
Reputation: 77523
alert
is disabled from background pages in WebExtensions.
Firefox does not support using
alert()
,confirm()
, orprompt()
from background pages.
Your console output probably works, but you need to be looking in the correct (background) console - not the currently displayed tab's console.
See the MDN documentation on debugging background pages ― the console is accessible through about:debugging
page.
Upvotes: 1