我想写一个Chrome扩展听取安装/卸载/启用/停用或者通过使用Chrome网上应用店或其他方式的其他扩展事件。chrome.management.onInstalled.addListener抛出未捕获的SyntaxError:意外的标识
我打算为此使用chrome.management模块。
我已经在manifest.json文件中声明了权限。
"permissions": [ "management" ],
我
"background": { "page": "background.html" },
我已经包括了background.js作为background.html页面
<html> <script type="text/javascript" src="js/background.js"></script> <body> </body> </html>
这里是一部分的background.html页我的背景.js
chrome.management.onInstalled.addListener(function(ExtensionInfo info) { console.log('somethingz installed...'); printInfo(info); }); chrome.management.onEnabled.addListener(function(ExtensionInfo info) { console.log('somethingz enabled...'); printInfo(info); }); chrome.management.onDisabled.addListener(function(ExtensionInfo info) { console.log('somethingz disabled...'); printInfo(info); }); function printInfo(info) { console.log("id: " ++ info.id); console.log("name: " ++ info.name); console.log("description: " ++ info.description); console.log("version: " ++ info.version); console.log("mayDisable: " ++ info.mayDisable); console.log("enabled: " ++ info.enabled); console.log("disabledReason: " ++ info.disabledReason); console.log("type: " ++ info.type); console.log("appLaunchURL: " ++ info.appLaunchURL); console.log("homepageUrl: " ++ info.homepageUrl); console.log("updateUrl: " ++ info.updateUrl ); console.log("offlineEnabled: " ++ info.offlineEnabled); console.log("optionsUrl: " ++ info.optionsUrl); console.log("icons: " ++ info.icons); console.log("permissions: " ++ info.permissions); console.log("hostPermissions: " ++ info.hostPermissions); console.log("installType: " ++ info.installType); }
我想通过看铬调试background.html页:// extensions页面,我看到 -
Uncaught SyntaxError: Unexpected identifier
和预期的,因为这个错误的事件不会开火。
请帮忙!!不知道是什么原因造成的“未捕获的SyntaxError:意外的标识符”错误...可能是东西太多基础,但是,我不能用它寻找相当一段时间内抓住它!
我觉得很蠢! :( 非常感谢你。 – Satya