0

I am writing a chrome extension, utilising content scripts and injecting HTML into a page. The HTML I plan to inject will be reasonably complex so I would prefer to write the HTML directly, rather than designing the nodes in JavaScript. I would like to have the HTML in a separate file in my chrome extension, and, using the content script, inject the contents of that file into a webpage.

I am quite new to JavaScript, but have become familiar with selecting, editing, deleting and adding HTML with the language, but I don't know how to access other files in JavaScript. I know it's basically impossible to access local file on the users machine, but I'm talking a file packaged in the chrome extension.

I know it is possible to inject a string in the HTML, but I would rather not write all my HTML into a single sting in JavaScript.

How can I access a file packaged in a chrome extension with JavaScript?

99lives
  • 798
  • 1
  • 8
  • 17
  • 1
    does this SO question help http://stackoverflow.com/questions/15873904/adding-complex-html-using-a-chrome-content-script – Jaromanda X Aug 23 '16 at 00:38
  • I never considered iframe. This should work. I never found this post during my googling :/ Cheers – 99lives Aug 23 '16 at 00:42

0 Answers0