如何在popup.html中发送我的数据?

时间:2018-04-09 15:16:04

标签: jquery google-chrome-extension

我是chrome扩展的新手,我正在尝试发送数组中的数据,并希望将其显示给我的弹出式HTML但我无法做到这一点我尝试通过链接,但我不知道为什么它不适合我。 这是我的代码,请检查错误在哪里: -

popup html: -

int i = sc.nextInt();
int count = 0;
while (i > 0)
{
  i /= 2;
  count++;
}

content.js: -

<div class="as-center button-info display-none div_three_main">
      <div class="img_area">
        <img src="images/right.png" alt="extension_logo" >
      </div>
      <p class="pop-up_text-heading">Success!</p>
      <p class="pop-up_text"> {count} members found. </p>
      <button class="input-btn scrap-button">Download CSV</button>
    </div>

background.js: -

var main = [];
var count = main.length;

chrome.tabs.sendMessage({ action: "count", count : 'count'});

popup.js: -

chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
    if (message["action"] == "new") {        
         chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
                if (tabs.length > 0) {
                    var msg = {action:'new',count:count};
                     chrome.runtime.sendMessage(msg);
                }
            });

    }
  });

请给我一个答案,从主阵列发送总元素,并在我的popup.html

中显示

0 个答案:

没有答案