Variables Chrome扩展:注入Javascript以设置变量
如何将Variables Chrome扩展:注入Javascript以设置变量,variables,google-chrome-extension,Variables,Google Chrome Extension,如何将注入将初始化变量的文档 内容和脚本: $("body").append('<script type="text/javascript">myvar="hi there";</script>'); $(“body”).append('myvar=“hi there””); 执行此操作时,无法识别变量myvar。。。 如果我添加一个简单的警报(500)我收到警报 基本上,我只想将扩展中的一个变量传递给文档,以便在那里使用它。addvar $("body").appe
注入将初始化变量的文档
内容和脚本:
$("body").append('<script type="text/javascript">myvar="hi there";</script>');
$(“body”).append('myvar=“hi there””);
执行此操作时,无法识别变量myvar
。。。
如果我添加一个简单的警报(500)代码>我收到警报
基本上,我只想将扩展中的一个变量传递给文档,以便在那里使用它。addvar
$("body").append('<script type="text/javascript">var myvar="hi there";</script>');
$(“body”).append('var myvar=“hi there”);
如果有那么简单,我会很高兴。不工作Hehe如果我从控制台执行此操作,它工作正常,您的版本也工作。。。。你什么时候注入/执行代码?事实上你是对的。jQuery无法完成看起来的工作;但你的方法2确实如此