Chrome扩展程序创建 - 未捕获的TypeError:无法读取未定义的属性“create”

时间:2017-07-11 21:15:24

标签: javascript google-chrome-extension

content.js: chrome.tabs.create({ url: 'http://www.sethjfreeman.com' });

manifest.json

{
    "manifest_version": 2,

    "name": "Secure Video Downloader",
    "description": "Download Videos Virus Free",
    "version": "1.0",
    "content_scripts": [
                         {
                             "matches": ["https://gostream.is/*", "http://gostream.is/*"],
                             "js": ["content.js", "jquery-3.2.1.min.js"],
                             "run_at": "document_end"
                         }
                  ],
    "browser_action": {
        "default_icon": "secure_16.png",
        "default_popup": "popup.html"
    },
    "permissions": [
        "tabs", "http://*/*"
    ]

}

说明
当页面加载时,我在尝试打开新标签时出现此错误

1 个答案:

答案 0 :(得分:0)

您无法访问注册网站上的chrome.tabs

您需要将邮件传递到background脚本并从那里调用chrome.tabs.create({ url: 'http://www.sethjfreeman.com' });

检查 Message Passing