【问题标题】:Call backround js method from popup js in Chrome Extension?从 Chrome 扩展中的弹出 js 调用背景 js 方法?
【发布时间】:2018-03-14 09:59:14
【问题描述】:

我需要从 popup.js 调用 background.js 中的一个方法。示例:

后台js:

function abc(){

}

弹窗js:

abc(); //call from here

【问题讨论】:

    标签: javascript google-chrome google-chrome-extension


    【解决方案1】:

    在 popup.js 中:

    var BGPAGE = chrome.extension.getBackgroundPage();
    BGPAGE.abc();
    

    也可以按照here的描述使用消息传递

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-06
      • 1970-01-01
      • 2016-05-15
      • 1970-01-01
      相关资源
      最近更新 更多