T_t
T_t

Reputation: 385

a simple problem about chrome extension. : )

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

Answers (2)

Dave
Dave

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

perimosocordiae
perimosocordiae

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

Related Questions