未经检查的runtime.lastError:无法建立连接。接收端不存在

时间:2019-03-07 13:27:11

标签: google-chrome google-chrome-extension

我正在尝试从网站向我的chrome扩展程序发送消息。超过错误。有什么希望吗?

I have added my website URL in 

manifest.json: 

"externally_connectable": {
    "matches": [
      "https://www.mywebsite.com/*"
    ]
}

background.js:

//My Listener
chrome.runtime.onMessageExternal.addListener(function(request, sender, sendResponse){
   console.log('::::::onMessage::::::::');
   sendResponse({a : 'SuccessResponse'});
});

//From Website am sending message like below
chrome.runtime.sendMessage('my_extension_id' , { 
  action: 'my_action_name'
}, function(response) { 
  console.log('response', response); 
}); 

0 个答案:

没有答案