接收端
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.消息id) {
}
});
获取当前标签页id并发送消息
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var currentTabId = tabs[0].id;
chrome.tabs.sendMessage(currentTabId,{消息id:消息内容})
});
向background.js发送消息
chrome.runtime.sendMessage({消息id:消息内容});
暂无评论