js读取配置文件自写


var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile("D:\\Useful Stuff\\Javascript\\mytest.txt",1);
var s = "";
while (!f.AtEndOfStream)
{
s+= f.ReadLine();
}
f.Close();

function getINI(item,key)
{
new RegExp("\\["+item+"\\](.+)").exec(s);
var str=RegExp.$1;
var reg2=https://www.jb51.net/(\w+)=(\d+)/;
var keyValue={};
str.replace(reg2,function(a,b,c){
keyValue[b]=c;
});
return keyValue[key];
}
alert(getINI("data","up"));
alert(getINI("plugin_page_search","hightlight"));

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdyxdx.html