我想从background.js访问popup.js
这是我的background.js
function abc(){
//call function of popup.js
xyz()
}
and this is popup.js
function xyz(){
//do something
}
答案 0 :(得分:0)
您可以使用Chrome事件
background.js:
chrome.runtime.sendMessage({yourMsg: 'Your Msg'});
popup.js:
chrome.runtime.onMessage.addListener(function(message) {
//here you can call your popup.js function
xyz()
});