David
David

Reputation: 7456

Communication between background.js and popup.js

I'm trying to build a chrome extension which stores links that I press while holding down shift and alt. This is my first chrome extension, and if I'm not mistaken, the way I'm supposed to do this is have a background.js which does the event handling for when I click on a link. Then, when I click on the link, I want popup.js to access that link somehow and display it on the page for later use. What would be the best avenue for this? Should I use localstorage, store the link in there, then when I open up popup.html have popup.js access it through localstorage and grab it to display it? Is there any way to have them directly communicate with each other?

Upvotes: 0

Views: 105

Answers (1)

Anton
Anton

Reputation: 317

You can directly access any methods/objects declared at background.js using chrome.runtime.getBackgroundPage. Check http://developer.chrome.com/extensions/runtime#method-getBackgroundPage for additional information.

Upvotes: 1

Related Questions