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>
manifest.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"
}
最佳答案
请求 webRequest
API 权限的正确方法是 webRequest
(不含 chrome。
)。
"permissions": [
"tabs",
"webRequest",
"webNavigation",
"management",
"http://*/*",
"https://*/*"
],
关于javascript - 如何使用 "chrome.webRequest.onBeforeRequest"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10277222/