无法阅读财产“onBeforeNavigate'未定义(Chrome扩展)

时间:2017-09-08 08:14:11

标签: javascript jquery api google-chrome google-chrome-extension

我很简单想要在“onBeforeNavigate'发生。但无论如何,扩展总是会出现这个错误:

Cannot read property 'onBeforeNavigate' of undefined 错误在此行chrome.webNavigation.onBeforeNavigate.addListener(setProxy);

到目前为止,这是我的代码:

popup.js

function setProxy(details){
    console.log("Got fired!\n");
}

chrome.webNavigation.onBeforeNavigate.addListener(setProxy);

的manifest.json

{
  "manifest_version": 2,

  "name": "Proxy Changer",
  "description": "This extension Changes the Proxy settings every time you load a website",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png"
  },

  "permissions": [
    "activeTab",
    "webRequest",
    "notifications",
    "debugger",
    "background",
    "management",
    "https://ajax.googleapis.com/",
    "<all_urls>",
    "webRequestBlocking"
  ],

  "background": {
    "scripts": ["popup.js"],
    "persistent": true,
    "js": ["jQuery.js", "popup.js"]
  }
}

我不想说我对Google Chrome扩展程序API很新,但对我来说,扩展API无效......我不知道我做错了什么.. 我已经看过视频但仍然出现同样的错误...

感谢您的帮助。谢谢你,亲切的问候!

0 个答案:

没有答案