Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Render a html document with its related js in the customrouteview #1

Open
ghost opened this issue Jul 9, 2015 · 3 comments
Open

Render a html document with its related js in the customrouteview #1

ghost opened this issue Jul 9, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 9, 2015

This simple example of hello is quite astoundingly easy to understand. I wonder what would I need to do have a html page replace that hello country string with its js and css.

@Macil
Copy link
Member

Macil commented Jul 9, 2015

You can append whatever elements you want to the view:

var div = document.createElement('div');
div.innerHTML = '<b>foo</b>';
customRouteView.getElement().appendChild(div);

You can place CSS into your extension by listing the files in the content_scripts section of your extension's manifest.json.

You could also put an HTML file into your extension and append it in an iframe if you specifically wanted the isolation that gives, but it's more work.

@aleemstreak
Copy link

Btw, that HTML string can come from AJAX'ing a remote HTML file or AJAX'ing
an html file in your chrome extension using chrome.runtime.getURL(
https://developer.chrome.com/extensions/runtime#method-getURL)

We'll add this soon to the docs and add some examples for best practicing
HTML/CSS loading.

On Thu, Jul 9, 2015 at 10:42 AM, Chris Cowan notifications@github.com
wrote:

You can append whatever elements you want to the view:

var div = document.createElement('div');
div.innerHTML = 'foo';
customRouteView.getElement().appendChild(div);

You can place CSS into your extension by listing the files in the
content_scripts section of your extension's manifest.json.

You could also put an HTML file into your extension and append it in an
iframe if you specifically wanted the isolation that gives, but it's more
work.


Reply to this email directly or view it on GitHub
#1 (comment)
.

@ghost
Copy link
Author

ghost commented Jul 9, 2015

'chrome.runtime.getURL' was the thing I was missing. Thanks a ton and yes, a simple example would be really helpful, for newbies. How to go on about having js associated to that html being loaded into the context?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants