If I'm using chrome.extension.getBackgroundPage(), I can access variables of the background.js like this:
background.js:
var transfer = 'some text';
popup.js:
chrome.extension.getBackgroundPage().transfer
But this says I get only a window object (but maybe 'JavaScript' before 'window' means something...). How can I access background variables?
If I'm using chrome.extension.getBackgroundPage(), I can access variables of the background.js like this:
background.js:
var transfer = 'some text';
popup.js:
chrome.extension.getBackgroundPage().transfer
But this says I get only a window object (but maybe 'JavaScript' before 'window' means something...). How can I access background variables?
Share Improve this question edited Dec 22, 2016 at 21:35 Jacob 2,1541 gold badge13 silver badges20 bronze badges asked Mar 22, 2013 at 14:18 dortonwaydortonway 4391 gold badge5 silver badges19 bronze badges1 Answer
Reset to default 18Yes, the word 'javascript' before window does mean that its returning the javascript file(page) background.js
For ease of access at the top of my popup.js
file I do this:
var background = chrome.extension.getBackgroundPage(); //do this in global scope for popup.js
then you can do this:
background.transfer;
Since you typically have to access your background page a lot, this just makes life easier all around.