在popup.js中,我使用以下代码显示当前选项卡的某个div id中的所有文本 - 并显示在alert中.我想知道如何将div文本保存到popup.js中的变量?
chrome.tabs.executeScript(null,code:"alert(document.getElementById(\"DIVid\").innerText.split(' '))"});
Run Code Online (Sandbox Code Playgroud)
以上工作正常,但当我尝试这个:
var getText = chrome.tabs.executeScript(null,code:"document.getElementById(\"DIVid\").innerText.split(' ')"});
Run Code Online (Sandbox Code Playgroud)
要么
var getText = chrome.tabs.executeScript(null,code:"document.getElementById(\"DIVid\").innerText.split(' ')"},function(response){return response});
Run Code Online (Sandbox Code Playgroud)
什么都没有存储.我显然是错误的做法.我究竟做错了什么?