如何将javascript文件作为文本文件读取并防止代码多次运行
index.js
version = "1.001";
alert("JS run");
... other code ...
我有html使用index.js
我尝试使用
jQuery.get("js/index.js",function(data){
var currentVersion = data.split("\n")[0].split('"')[1];
}
我可以按照自己的意愿阅读文字,但警报(“JS run”)和其他代码也在我使用此代码后运行。