I am trying to send a message from background.js
to content.js
using the following code:
Background
chrome
There are 2 sendMessage
functions in Chrome API.
So, to send a message TO a content script, you need to use chrome.tabs
. To send a message FROM a content script (or within the extension pages), you need to use chrome.runtime
.
The event is chrome.runtime.onMessage
in both cases.
See Messaging docs for more details.