Can You Use Javascript In A Page Action Popup?
Solution 1:
First of all, Chrome extensions are not allowed to run inline Javascript Code (aka any piece of code that is not included inside a .js file, but in the DOM).
Quoting from the Content Security Policy page:
There is no mechanism for relaxing the restriction against executing inline JavaScript. In particular, setting a script policy that includes 'unsafe-inline' will have no effect.
Therefore, you'll need to put your code inside another file and import it, like this:
<sctiptsrc="popup.js"></script>
Secondly, the code you run into the popup is logged in its own console, so you have to right-click on your extension's icon, and hit "Inspect popup". Then, a developer tools window will appear, and you'll be able to browse to the "Console" tab and see the log. Alternatively, you can open the popup and right click anywhere inside it, then choose "Inspect element", like on any normal page.
Post a Comment for "Can You Use Javascript In A Page Action Popup?"