1つのメッセージインターフェイスを使用して、ポップアップとバックグラウンドページの間でメッセージを渡そうとしています(このためのGoogleの例のコードと同様のコードを使用しています)。
現れる:
chrome.extension.sendMessage( {msg: "this is popup's msg"}, function(b){
alert('this is popups callback func' +b.backgroundMsg);
});
これが私がbackground.jsで聞く(そして返信する)方法です:
chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) {
sendResponse({backgroundMsg: "this is background msg"});
});
コンソールですべてを検査すると、メッセージは正常に交換されますが、次のエラーが発生します。
Error in event handler for 'undefined': Cannot call method 'disconnect' of null TypeError: Cannot call method 'disconnect' of null
at chromeHidden.Port.sendMessageImpl (miscellaneous_bindings:285:14)
at chrome.Event.dispatch (event_bindings:237:41)
at Object.chromeHidden.Port.dispatchOnMessage (miscellaneous_bindings:250:22)
何かご意見は?