我曾尝试浏览此处发布的类似问题,但似乎没有一个有效
清单.json
{
"manifest_version": 2,
"name" : "A simple Found Text Demo",
"description" : "Bla",
"version" : "1.0",
"background" : {
"pages" : "background.html"
},
"page_action" : {
"default_icon" : "icon.png"
},
"content_scripts" : [{
"matches" : ["*://*/*"],
"js" : ["contentscript.js"]
}]
}
背景.html
<html>
<script>
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse){
alert(request);
//chrome.pageAction.show(sender.tab.id);
sendResponse('Found!');
}
)
</script>
</html>
内容脚本.js
chrome.extension.sendMessage({"name" : "hola"}, function(res){
console.log(res); })
但是我反复得到同样的错误:
Port error: Could not establish connection. Receiving end does not exist.
有任何想法吗?