我在我的服务器中托管了这个HTML文件:
select(2)
这是我的<html>
<head>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$( document ).ready(function() {
var editorExtensionId = "fblmefappkgpogjehblfmlhfnfpnnlep";
chrome.runtime.sendMessage( editorExtensionId, "Eat This!" );
alert("perfect!"); << ** this show up, so I assume sending message to chrome runtime also works **
});
</script>
</body>
</html>
文件:
manifest
这是我的"content_scripts": [
{
"matches": ["*://*.mydomain.com/*", "*://mydomain.com/*"],
"js": ["myscript.js"]
}
],
"externally_connectable": {
"matches": ["*://*.mydomain.com/*", "*://mydomain.com/*"]
}
文件:
myscript.js
每当我打开chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
alert (request);
});
时,mydomain.com
都没有提醒。似乎chrome.runtime.onMessageExternal.addListener
没有“监听”任何东西并且无法从jquery接收消息。我错过了什么?谢谢。