我正在尝试构建一个与内部应用程序交互的扩展,并且我正在查看外部消息传递内容的文档,但是每当我尝试访问时chrome.runtime.onMessageExternal.addListener
,我都会收到一条错误消息,说chrome.runtime.onMessageExternal
未定义。同样的事情onConnectExternal
清单,json
{
"manifest_version": 2,
"name": "My Extension",
"description": "My Desc",
"version": "0.2",
"externally_connectable": {
"matches": [
"http://*.mysite.com/*"
]
},
"author": "Aaron Scherer",
"content_scripts": [
{
"matches": [
"http://*.mysite.com/*"
],
"js": ["js/script.js"]
}
]
}
js/script.js
chrome.runtime.onMessageExternal.addListener(
function( request, sender, sendResponse ) {
debugger;
console.debug( request );
console.debug( sender );
console.debug( sendResponse );
} );
网站的js
chrome.runtime.sendMessage( 'myextid', { test: 'test' } );