Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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 在另一个js文件中加载外部js文件_Javascript_Jquery - Fatal编程技术网

Javascript 在另一个js文件中加载外部js文件

Javascript 在另一个js文件中加载外部js文件,javascript,jquery,Javascript,Jquery,我的html中包含了这个文件,我想从另一个javascript调用它。 请建议我该怎么做 <script type="text/javascript" src="js.js">/* old:123 new: 456*/ </script> /* 旧:123 新:456*/ 我想把它包含在我的js文件中,而不是html中。如果你想在js中包含js文件,你可以使用它 如果不能使用jQuery var imported = document.createElemen

我的html中包含了这个文件,我想从另一个javascript调用它。 请建议我该怎么做

<script type="text/javascript" src="js.js">/*
  old:123
  new: 456*/
</script>
/*
旧:123
新:456*/

我想把它包含在我的js文件中,而不是html中。

如果你想在js中包含js文件,你可以使用它

如果不能使用jQuery

var imported = document.createElement('script');
imported.src = '/path/to/imported/script';
document.head.appendChild(imported);


有关W3当前CSP3规范的更多信息,请查看。

没有可调用的…?您想做什么?也。。这种使用JavaScript块的方法是无效的,无法工作/请检查此脚本块是否在html的头部。。不在js文件中。我想用另一个js文件做同样的事情。你可以使用服务器端语言来生成动态js脚本,所以用参数调用它会生成其他东西。这就是我所能提供的,如何传递参数?旧的:123新的:456关于你必须传递参数的内容???@Gaurav请查看这篇文章到js,比如linkedIn jsapi@Gaurav我会在脚本中添加那些LinkedIn变量,如果您正在设置它们的话
var imported = document.createElement('script');
imported.src = '/path/to/imported/script';
document.head.appendChild(imported);