-2

In my Chrome extension I have included jquery.min.js in manifest file like this http://codepaste.net/ve31sq

But I can't seem to execute this code part in background.js

function getNparse() {
    jAlert('This is a custom alert box', 'Alert Dialog');
}
Amal G Jose
  • 2,486
  • 1
  • 20
  • 35
Deniz da King
  • 381
  • 1
  • 4
  • 12

1 Answers1

2

A background page never gets any content scripts injected. It's not an http:// page to begin with, but even then it's not possible to specify a match pattern for it.

If you need jQuery there (along with plugins), you need to list it as a background script:

  "background": {
    "scripts": ["jquery.min.js", "jAlert-v2.js", "background.js"]
  },

Do note: the background page is invisible. Showing a custom alert on it won't help you anyhow. Looks like you're confised about how extensions work; start with the Overview page.

Also, you should learn to debug the background page.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • Then how do I link my functions to contentscript.js. Now my extension works like this: 1) popup.html (button pressed) 2) popup.js (added eventListener, and forwarded to background.js via chrome.extension.sendMessage). Here I want to make modifications on the web page I'm looking (like alerts, parsing tables, change values or add html to the document). – Deniz da King Jun 03 '15 at 12:40
  • Read the overview I linked; it's covered there. You'll need a content script and Messaging between it and other parts. – Xan Jun 03 '15 at 12:41