Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome app: Why can't i modify the page?
    primarykey
    data
    text
    <p>This is probably a super basic question but I cant seem to find a straight answer anywhere...</p> <p>Why doesn't the <code>document.getElementById('pID').innerHTML = 'test';</code> change the text inside the p element? also the <code>console.log('test');</code> isnt working either...</p> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;p id="pID"&gt;Hello, world!&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; &lt;script src="main.js"&gt;&lt;/script&gt; </code></pre> <p>JAVASCRIPT:</p> <pre><code>chrome.app.runtime.onLaunched.addListener(onLoad); function onLoad() { chrome.app.window.create('window.html', { 'bounds': { 'width': 400, 'height': 900 } }); } </code></pre> <p>MANIFEST.JSON:</p> <pre><code>{ "name": "Hello World!", "description": "My first Chrome App.", "version": "0.1", "app": { "background": { "scripts": ["background.js"] } } } </code></pre> <p>MAIN.JS:</p> <pre><code>function onLoad() { console.log('test'); document.getElementById('pID').innerHTML = 'test'; } window.onload=onLoad;//This is what I was missing! </code></pre> <p>@rshanchez: I changed it and i get the following error (still doesnt work):</p> <p><em>Refused to execute inline event handler because it violates the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.</em></p> <p>@rshanchez: I made the window.onload=onLoad; and that did it. Thanks for the help! If you want the rep points answer the question and i'll mark it as answered... Otherwise +1 to awesomeness for you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload