Tuesday, 30 August 2016

Function JavaScript between popup.html and popup.js in chrome extension (taking into account message from Background)

I would like to execute function in chrome extension (in popup.js) by clicking on button in a innerHTML.



My code in popup.html is:
















My code in popup.js :



chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.text === 'results') {
var panier_container = document.getElementById("panier_container");
var texte = "";
panier_container.innerHTML = texte;
});
});


function toto() {
alert("toto");
}


When I execute the code, I see the button "TOTO" but when I click on the button, nothing happen. Out of chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { the button execute the function. But inside no.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...