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 – 2012-02-09 10:43:01
您可以在http://new.crbug.com提交请求/注意到混乱?如果有一些简单的东西,我们可以添加到那个可以清楚地说明这个用例的页面,我很乐意去做。 – 2012-02-09 10:45:20
这可能并不令人困惑,我只是误解了文档。 – 2012-02-09 11:09:18