Home > front end >  Chrome plug-ins, how in chrome. Tabs. ExecuteScript referenced within the script file called backgro
Chrome plug-ins, how in chrome. Tabs. ExecuteScript referenced within the script file called backgro

Time:04-05

Below is the background of plug-in js related content, but the AutoFill. Js code in the background can be accessed. The variables in js var_t, the steps of how to make the call file access var_t variables?

Background. Js:
 
Var var_t="var variable";
Chrome. ContextMenus. Create ({
Title: "right-click menu,"
Id: "1",
Onclick: function () {
Chrome. Tabs. ExecuteScript (null, {file: "js/AutoFill js"});
}
});


AutoFill. Js:
 
Alert (var_t);

Here just to illustrate how to use, just write the alert (var_t); Runtime, chrome error, var_t undefined,

CodePudding user response:

AutoFill. Visit js var_t, make sure you var_t is a global variable

CodePudding user response:

Thank you, I don't so defined is the global variable?
  • Related