Linked Questions

Popular Questions

Chrome Extension Background Function

Asked by At

I'm trying to define a background function and use it in popup.js. Because, I want to send POST request and don't know a way to do it in popup.js. I've searched for it and so many people just say, it's better to send a POST request in background.js. And chrome blocks the request from popup.js.

Here is my manifest.json:

{
    "name": "Getting Started Example",
    "version": "1.0",
    "description": "Build an Extension!",
    "permissions": [
        "declarativeContent",
        "activeTab",
        "tabs",
        "storage",
        "webNavigation",
        "<all_urls>"
    ],
    "background_page": "background.html",
    "background": {
      "scripts": ["background.js"],
      "persistent": false
    },
    "page_action": {
      "default_popup": "popup.html",
      "default_icon": {
        "16": "icon-16.png",
        "48": "icon-48.png",
        "128": "icon-128.png"
      }
    },
    "icons": {
        "16": "icon-16.png",
        "48": "icon-48.png",
        "128": "icon-128.png"
      },
    "manifest_version": 2
  }

How can I do it?

Related Questions