Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.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
Javascript 如何从我的Chrome扩展名';谁的背景剧本?_Javascript_Google Chrome_Google Chrome Extension - Fatal编程技术网

Javascript 如何从我的Chrome扩展名';谁的背景剧本?

Javascript 如何从我的Chrome扩展名';谁的背景剧本?,javascript,google-chrome,google-chrome-extension,Javascript,Google Chrome,Google Chrome Extension,我正在使用ChromeAPI中的以下代码制作Google Chrome扩展: chrome.tabs.executeScript(null,{file : 'inject.js'},function(){}) 现在我想从文件inject.js中获取用于回调函数的值,但我不知道如何做到这一点。有人能帮我吗 chrome.extension.getBackgroundPage()返回当前扩展中运行的背景页面的JavaScript“窗口”对象 变量必须在全局范围内可访问才能工作。例如: var ou

我正在使用ChromeAPI中的以下代码制作Google Chrome扩展:

chrome.tabs.executeScript(null,{file : 'inject.js'},function(){})
现在我想从文件
inject.js
中获取用于回调函数的值,但我不知道如何做到这一点。有人能帮我吗

chrome.extension.getBackgroundPage()
返回当前扩展中运行的背景页面的JavaScript“窗口”对象

变量必须在全局范围内可访问才能工作。例如:

var outer_result = 0;
function example() {
    var inner_result = 1;   // <-- local variable
    outer_result = 2;       // <-- global variable
}
// 'inner_result' is undefined outside the function.
// You can only use 'outer_result' from other scripts.
var外部结果=0;
函数示例(){

var internal_result=1;//您读过文档了吗?您能详细解释一下“值”是什么意思吗?我正在使用当前选项卡中的get-iframe卡进行扩展,并创建一个名为jcvideos的变量来保存它们(使用一些函数来执行)在那之后,我想得到jcvideos的值,以便在我的另一个名为background.js的javascript文件中使用它,在上面的代码中详细说明(在function(){})。我已经阅读了Chrome Developer的文档以寻求帮助,但是信息是模棱两可的,我无法理解。我可能重复了上面的问题,但它使用了{code:},我不知道它是否与我的案例不同(我使用{file:…})。对不起,我没有这样做。
var outer_result = 0;
function example() {
    var inner_result = 1;   // <-- local variable
    outer_result = 2;       // <-- global variable
}
// 'inner_result' is undefined outside the function.
// You can only use 'outer_result' from other scripts.