0
我正在創建一個Chrome擴展,我遇到了這個非常惱人的問題。我想從我的內容腳本發送一條消息到後臺併發送回應。chrome.runtime.sendMessage不工作
Port: Could not establish connection. Receiving end does not exist
我目前使用此代碼:
我不斷收到此錯誤。
背景:
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse){
sendResponse("got it!");
});
內容腳本:
chrome.runtime.sendMessage(<extension id>, "test message", function(response){
console.log(response);
});
我使用的Chrome版本30.0.1599.69米
在內容腳本