2
バックグラウンドページをGoogle Chromeの拡張機能のポップアップと通信させようとしています。Chrome拡張機能:ポップアップにバックグラウンドページからのリクエストを送信
私はそれを他の方法で動作させることができましたが、何らかの理由で今は動作しません。
// background.html
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {
method: 'countDown',
seconds: seconds,
id: id
}, function(response) {
console.log(response.farewell);
});
});
// popup.html
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
console.log('request from background');
if(request.method == 'countDown') {
console.log(request.seconds);
//countDown(request.id);
}
sendResponse({});
});
権限は適切です(バックグラウンド、タブ)が、バックグラウンドが要求を送信していないようです。
うわー、うまくいきます。なぜ私がchrome.tabsを使用していたのか分かりません。ドキュメントが少し混乱していた可能性があります。http://code.google.com/chrome/extensions/messaging.html –
http://new.crbug.comでリクエストできますか? /混乱に気づいた?このユースケースを明確にするために、そのページに簡単に追加できるものがあれば、私はそれを行うことを嬉しく思っています。 –
おそらくあまり混乱しないでしょう、私はその文書を誤解しました。 –