Answer the question
In order to leave comments, you need to log in
How to send message from background to popup?
You can send a message from popup.js to the background (chrome.runtime.sendMessage), and get the response in the callback. But if the response cannot be sent immediately, then the connection is closed.
It would be convenient to make a message listener in the popup, like this:
// popup.js
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
console.log(msg);
});
// background.js
chrome.tabs.sendMessage(id, data, function (r) {
console.log(r);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question