简体   繁体   中英

How to load scripts on url override on new tab in chrome extension?

My manifest.json looks like this.

    {
      "manifest_version": 2,

      "name": "Getting started example",
      "description": "This extension shows a Google Image search result for the current page",
      "version": "1.0",

      "chrome_url_overrides" : {
        "newtab": "a.html"
      }
    }

I want to include myScript.js and jquery.js on a.html.

I have tried using script tags on a.html( which do not work as inline script not allowed).

Dabbled with content script and background page.But I don't think I need content script here since I am not looking for interaction with current page content.I think this can be accomplished by background page but it does not seem to be working.I have tried adding "background": { "scripts": ["jquery.js", "myScript.js"] } to manifest.json but it does not seem to work.

How do I add myScript.js and jquery.js to a.html.

PS: All files are in same directory.

Try adding external JS as:

<script src="myScript.js"></script>

to a.html page and creating myScript.js and writing your JS Code in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM