그래서 나는 탭에서 수신 배경 페이지크롬
var tabHandler={
onTabUpdate:function(tabId, changeInfo, tab){
},
tabChanged:function(activeInfo) {
function tabChanged(tab){
var parser = document.createElement('a');//To extract the hostname, we create dom element
parser.href = tab.url;
var regex=/^(www\.)?([^\.]+)/
var matches=regex.exec(parser.hostname)//This gives us the hostname, we extract the website name
var website=matches[2];
var data=getDataForWebsite(website);//Data is a json array
//TRANSFER 'data' to Browser popup so that it can be displayed.
}
chrome.tabs.get(activeInfo.tabId,tabChanged);
},
init:function(){
chrome.tabs.onActivated.addListener(this.tabChanged);
}
}
tabHandler.init();
이 코드 조각이 웹 사이트의 남를 얻을 수를 변경하고 기반으로 매개 변수의 목록을 가져 오는 한 브라우저 작업에 배경 페이지에서 데이터를 전송 웹 사이트. 이제 데이터가 생겼으므로이 데이터를 브라우저 조치 팝업에 표시하는 방법에 대해 궁금합니다. 이 데이터를 브라우저 Action Adn에 전달한 다음 기존 콘텐츠를 바꿉니다. 어떻게해야합니까?
하지만 팝업 **이 아직 열리면 어떻게 될까요? 그러면 어떻게 메시지를 전달합니까? – Pacerier
확장 프로그램 내에서 일반 메시지 전달을 사용하면됩니다 (https://developer.chrome.com/extensions/messaging). –