D
D
Denis Ilinykh2012-02-15 17:08:18
Google Chrome
Denis Ilinykh, 2012-02-15 17:08:18

How to call a Function from Chrome.Extension

There is a chrome extension in it there is a Content script
Inside it there is a function on the site page there is a button But Chrome writes that “alertme is not defined” At the same time, the test alert triggered by onload in the content script works.
function alertme(){
alert("hi");
}


<input type="button" value="Hi" onclick="alertme()">


Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly, 2012-02-15
@taliban

addEventListener to help you, and install it from the extension. Ato would be too major to drag data from extensions.

K
Konstantin Kitmanov, 2012-02-15
@k12th

Impossible. Content scripts from extensions run in the sandbox and can only interact with the client script through the DOM (they share it).
That is: The
content script knows nothing about the variables and functions defined on the page.
The JS on the page knows nothing about the variables and functions defined by the content scripts.
All this is written more than once in the docks for Chrome extensions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question