H
H
habrdima2015-07-06 20:53:54
JavaScript
habrdima, 2015-07-06 20:53:54

How to connect popup.html and background extensions?

The extension has a background or content script, I need to get data from there or send data there using popup.html, how can I do this? I know XmlHttpRequest can do this, but are there built-in API's for this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin   , 2015-07-23
@SynCap

There are a lot of options with intermediate storage: in the background DOM element, in localStorage, in indexedDB, in appCache. And you can track events for WebWorker.

B
BulatDos, 2015-08-16
@BulatDos

Load popup.html at the end and jquery for convenience

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="background.js"></script>

And you can just access by id. And to interact with the content script, it is better to use messages in json format.
https://developer.chrome.com/extensions/tabs#metho...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question