I am creating a Google Chrome extension (my first) and I want to send messages from the extension to the current tab.
I follow the documentation:
https://developer.chrome.com/apps/runtime#event-onMessage
The extension loads a small external JS into the HTML code of the tab, which contains the following code:
chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { console.log(request) } );
As soon as JS loads, I get the following error:
Uncaught TypeError: Cannot read property 'onMessage' of undefined .
Open the console and type chrome , I see that the runtime is not a chrome property.
It sounds like I'm doing something wrong, but what? Do I need to add something to the manifest.json file?
Chrome version 39.0.2171.71 m
Thanks.
javascript google-chrome-extension
igasparetto
source share