I-Parliament
I-Parliament

Reputation: 115

Popup.html not opening in chrome extension

The popup.html file is not opening when I click the extension button. The chrome extension is also changing the newTab through the main.html file. But the popup does not show, neither does the "inspect Pop Up" button. Why is this happening?

Manifest.json:

{
  "name": "Name",
  "description": "Add description",
  "version": "0.1.9.2",
  "browser_action": {
    "default_icon": "icon.png",
   "default_popup": "popup.html"
 },
  "permissions": [
    "activeTab"
  ],
  "chrome_url_overrides" : {
    "newtab": "main.html"
  },
  "background": {
    "scripts": ["jquery-2.2.3.min.js", "background.js"],
    "persistent": false
  },
  "icons": { "16": "icon16.png",
            "24": "icon24.png",
              "32": "icon32.png",
           "48": "icon48.png",
           "64": "icon64.png",
          "128": "icon128.png",
          "256": "icon256.png",
          "512": "icon512.png"
         },

  "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/",
    "storage",
    "tabs",
    "http://*/*",
    "https://*/*"
  ],
  "browser_action": {
    "default_title": "app"
  },
  "manifest_version": 2
}

Popup.html:

<!doctype html>
  <html>
   <head>
    <style type="text/css">
        body {
            width: 200px;
            height: 200px;
        }
    </style>
   </head>
   <body>
    TEXT TEXT TEXT
   </body>
  </html>

Upvotes: 3

Views: 3702

Answers (1)

Xan
Xan

Reputation: 77591

You have 2 browser_action sections in your manifest:

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },

  ...

  "browser_action": {
    "default_title": "app"
  },

When the manifest is parsed, it's not a syntax error* but the second one overwrites the first one. So you no longer have a default_popup.

You should merge them into one key:

  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html",
    "default_title": "app"
  },

* Technically, duplicate keys are not disallowed by the JSON standard: SHOULD but not MUST have no duplicate keys; as such, implementation-dependent.

Upvotes: 3

Related Questions