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?
Yes, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With