0

So my question is this: i have a box.html that contains some <div>s. It is way too big to be stored as a string in the background script. It would be very inconvenient to change anything in the html if it was stored as just a string variable.

What I can't figure out is how to access that file from background.js so that all of the html is then stored in a variable like var box = "some html"

So that when I have that variable I can then pass it on to a content script when I need it.

I know that chrome.extension.getURL('box.html'); gets the path to the file I need, but how do I load the file?

in Firefox this is simply done with: self.data.load('box.html'); in the main.js so is there a similar call for google chrome?

Andriy Lysak
  • 384
  • 5
  • 15

1 Answers1

1

I've used a simple ajax request through jQuery to solve this in the past:

var myDiv = document.queryElement('my_div');

$.get(chrome.extension.getURL('box.html'), function(data) {
  myDiv.innerHTML = data;
});
anderspitman
  • 9,230
  • 10
  • 40
  • 61