2

Chrome 一直说:“无法读取未定义的属性 'onBeforeRequest'”。我不知道为什么。

背景.html:

<html>
  <head>
    <script type="text/javascript">// <![CDATA[     
         try 
            {
                chrome.webRequest.onBeforeRequest.addListener(function(e){alert("onBeforeRequest")},{urls: ["http://*/*", "https://*/*"]}, ["blocking"]) ;
                 }
            catch (ErrorMessage)
            {
              alert('page:'+ErrorMessage) ;
            }       


    // ]]></script>
    </head>
</html>

清单.json:

{
  "name": "first extension",
  "version": "1.0",
  "description": "first extension",
  "browser_action": {
    "default_icon": "icon.gif",
    "popup": "popup.html"
  },

  "permissions":
  ["tabs", "chrome.webRequest", "webNavigation", "management", "http://*/*", "https://*/*"],
  "background_page": "background.html"
}
4

1 回答 1

3

请求webRequestAPI 权限的正确方法是webRequest(不带chrome.)。

"permissions": [
    "tabs",
    "webRequest",
    "webNavigation",
    "management",
    "http://*/*",
    "https://*/*"
],
于 2012-04-23T15:36:44.217 回答