在使用javascript检测Chrome扩展程序时检测错误

sar*_* mp 3 javascript jquery google-chrome google-chrome-extension google-chrome-devtools

这是我的代码,

var myExtension = chrome.management.get( "my_extention_id" );
if (myExtension.enabled)
{
// installed
}
else { ... }
Run Code Online (Sandbox Code Playgroud)

来源:http://developer.chrome.com/extensions/management.html#method-get 我试过这个方法.但我得到以下错误:未捕获的TypeError:无法读取未定义的属性'get'

gre*_*oul 6

签入另一个分机:

https://gist.github.com/greatghoul/321b4f32c0b7a6ad8a97

检查网页

https://developer.chrome.com/extensions/messaging#external-webpage

在清单文件中,记得注册要检查扩展名的网页.

"externally_connectable": {
    "matches": ["*://developer.chrome.com/*"]
}
Run Code Online (Sandbox Code Playgroud)

然后你可以chrome.runtime.sendMessage在那个页面中使用.