Reputation: 385
I am a beginner with chrome extension. In my content_script.js, how can a get an array in Javascript from background.html?
Upvotes: 1
Views: 938
Reputation: 21
you have to use message passing which I am finding a pain to use, but anyway details here
http://code.google.com/chrome/extensions/messaging.html#connect
Upvotes: 1
Reputation: 17847
I did it like this: (assuming you have an array foo in background.html)
chrome.extension.getBackgroundPage().foo
But apparently, that only works for things like popup.html, etc. To get data from your background page in a content_script.js file, you need to use:
chrome.extension.connect()
The API docs are here.
Upvotes: 3