Is javascript in a html file possible?

learning

#1

As a total newbie I try to make a simple addon. Clicking on the extension would result in showing a html page, with an extra search option for Google (Timesearch).
The script in the html file works, but if I activate it within the extension nothing happens.
Perhaps it isn’t possible to activate javascripts in extensions?

Source:

Background.js
function openwebsite() {
console.log(“injecting”);
browser.tabs.create({
“url”: “/website.html”
});
}
browser.browserAction.onClicked.addListener(openwebsite);

Contents of this html page
http://members.home.nl/khdevries/timesearch.html


(Martin Giger) #2

You can’t have inline scripts due to the CSP for extensions. You have to put your JS in a separate file that is loaded via <script> tag. You then bundle both in your extension.


#3

Thanks for your quick reaction!
I’ll study it.