Can you use javascript in the page action popup?

I am trying to create a chrome extension that uses a page action popup menu, but none of my javascript seems to work. Here is the source:

<!DOCTYPE html>
<html>
    <body>
        <input type="button" id="button1" value="first button">
        <input type="button" id="button2" value="second button">
        <script>
           console.log("do anything!!");
        </script>
    </body>
</html>

I do not see anything in the log instructions. I can't seem to run anything. So how should popups work? The docs don't mention that these popups are just static HTML.

+4
source share
1 answer

First of all, Chrome extensions are not allowed to run the built-in Javascript Code (for example, any piece of code that is not in the .js file, but in the DOM).

:

JavaScript. , script, "-", .

, :

<sctipt src="popup.js"></script>

-, , , , "Inspect popup". , "" . , , " ", .

enter image description here

+5

Source: https://habr.com/ru/post/1570770/


All Articles