Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome extension background page html not working
    primarykey
    data
    text
    <p>I am trying to understand chrome background pages. I managed to get background.js script running after cannibalizing on the of examples and it pops up with an alert box every time a user visits a page. However, when I take the same script and move it to a background.html file, I cannot seem to get the file to execute.</p> <p>I have updated the the manifest file to a page (instead of script) and the extension loads fine. I have also tried playing around with either having the javascript in a script tag directly in the body or in a function as it is now that is called onload on the body or in the head.</p> <p>Perhaps I don't understand the concept of what a background.html page is used for in a Chrome extension?</p> <p>Manifest file:</p> <pre><code>{ "name": "Testing Extension", "version": "0.2", "background": { "pages": ["background.html"] }, "permissions": [ "tabs", "https://mail.google.com/*", "http://*/*, https://*/*" ], "browser_action": { "name": "Do some action", "icons": ["icon.png"] }, "manifest_version": 2, "web_accessible_resources": ["injectImage.js", "background.html"] } </code></pre> <p>injectImage.js</p> <pre><code>alert('Got Here'); 'use strict'; chrome.browserAction.onClicked.addListener(function (tab) { chrome.tabs.executeScript(null, {file: "injectImage.js"}); }); chrome.browserAction.setBadgeBackgroundColor({color: [0, 200, 0, 100]}); var i = 0; window.setInterval(function () { chrome.browserAction.setBadgeText({text: String(i)}); i++; }, 10); </code></pre> <p>background.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="jquery-1.8.0.min.js"&gt;&lt;/script&gt; &lt;script src="injectImage.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>currently this code doesn't seem to do anything other than put an icon in the top right corner.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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