Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome Chrome扩展:Show modified background.html_Google Chrome_Google Chrome Extension - Fatal编程技术网

Google chrome Chrome扩展:Show modified background.html

Google chrome Chrome扩展:Show modified background.html,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我有一个数据数组,我想显示给扩展的用户。我想操纵后台页面并用数据填充它,然后通过:chrome.tabs.create({url:chrome.extension.getURL('background.html'))向用户显示它 但是,这将打开一个全新的background.html页面,该页面不会被操纵,而且,与原始的background.html完全不同 i、 e在新页面中,我无法访问要向用户显示的阵列 我还尝试了一个不同于background.html->results.html的页面…

我有一个数据数组,我想显示给扩展的用户。我想操纵后台页面并用数据填充它,然后通过:
chrome.tabs.create({url:chrome.extension.getURL('background.html'))向用户显示它

但是,这将打开一个全新的background.html页面,该页面不会被操纵,而且,与原始的background.html完全不同

i、 e在新页面中,我无法访问要向用户显示的阵列

我还尝试了一个不同于background.html->results.html的页面……我得到了它的url,然后用我想显示给用户的数组向它发送一条消息:

chrome.tabs.create({url:chrome.extension.getURL('results.html')),函数(tab){
sendMessage(tab.id,{'personsarray':persons});
});

然后在results.js中:

chrome.runtime.onMessage.addListener(
功能(请求、发送方、发送响应){
控制台日志(请求);
//其他业务
});

但消息似乎没有被发送!在控制台中找不到任何内容

问题:

  • 是否可以使用background.html页面向用户显示数据

  • 在chrome extensions中向用户显示数据的适当方式是什么

  • 为什么我没有收到从background.js发送到results.js的消息


  • 后台页面之间的访问不受限制。创建results.html时,下一步应该是调用chrome.runtime.getBackgroundPage()从results.html的javascript页面获取后台页面窗口对象。该对象将包含background.html中的所有数据和对象。

    后台页面彼此之间具有不受限制的访问权限。当您创建results.html时,下一步应该是调用chrome.runtime.getBackgroundPage()从results.html的javascript页面获取后台页面窗口对象。该对象将包含background.html中的所有数据和对象