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"
}