I wanted to know how to import a javascript file from a source like pastebin.com/raw or dl.dropboxusercontent.com into a javascript file. I'm talking about a solution similar to the @import ""; in CSS.
我想知道如何将来自像pastebin.com/raw或dl.dropboxusercontent.com这样的源的javascript文件导入到javascript文件中。我在谈论类似于@import的解决方案“”;在CSS中。
I'm not trying to interfere the HTML in anyway (e.g.)
无论如何我都不想干扰HTML(例如)
<script src="http://pastebin.com/raw/xxxxxx">
1 个解决方案
#1
0
var firstScript = document.getElementsByTagName('script')[0],
js = document.createElement('script');
js.src = 'https://pastebin.com/raw/xxxxx';
firstScript.parentNode.insertBefore(js, firstScript);
#1
0
var firstScript = document.getElementsByTagName('script')[0],
js = document.createElement('script');
js.src = 'https://pastebin.com/raw/xxxxx';
firstScript.parentNode.insertBefore(js, firstScript);