问题描述
我正在开发Chrome中的扩展程序,并且存在问题。在我的 inject.js
中,我提出了一个请求:
chrome .extension.sendRequest({command:'skip'},callback)
和我的背景。 js我简单地添加一个请求监听器,如:
chrome.extension.onrequest.addListener(function(req,sender,res){ console.log(procession})
但出现错误:
端口错误:无法建立连接。接收端不存在
这似乎是Chrome中的一个错误?
PS:
是我的manifest.json的一部分
background:{
scripts:[background.js]
},
content_scripts:[
{
matches:[& lt all_urls& gt ],
js:[inject.js]
}
],
我在Chromium 17中,尝试重新加载扩展程序,重新打开浏览器...什么都没有发生
some on e得到一些想法?
我发现自己遇到了与您在此处描述的相同的问题。我找到的解决方案是使用backgroundpage而不是后台脚本,如下所示:
background_page: src / background.html,
//也许这似乎是工作而不是背景{scripts []}
/ *这给出端口错误:不能...
background:{
scripts:[src / background.js]
},
* /
我希望这也适用于您。
I'm developing an extension in Chrome, and there's a problem. In my inject.js
, I make a request like:
chrome.extension.sendRequest({command:'skip'},callback)
and in my `background.js I simply add a request Listener like:
chrome.extension.onrequest.addListener(function(req,sender,res){console.log("procession"})
But there's an error:
Port error: Could not establish connection. Receiving end does not exist
It seems a bug in chrome?PS:
part of my manifest.json
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["< all_urls >"],
"js": ["inject.js"]
}
],
I'm in Chromium 17, and I tried reloading the extension, reopening the browser... nothing happened
some one get some ideas?
I found myself having the same issue as you describe here. The solution I found that works for me is to use a backgroundpage instead of a background script, like so:
"background_page": "src/background.html",
// maybe this seems to work instead of background { scripts [] }
/* this gives a Port error: Could not ...
"background": {
"scripts": ["src/background.js"]
},
*/
I hope this works for you too.
这篇关于端口错误:无法建立连接。接收结束不存在。在Chromiume的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!