js读取配置文件自写
时间:2024-04-17 09:51:37
自己写的用js读取配置文件的程序
D:\Useful Stuff\Javascript\mytest.txt
文件内容如下
[plugin_page_search]
wholeword=0
matchcase=1
hightlight=1
total=1
[data]
up=85
down=5
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=/(\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"));
标签:读取配置文件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Vue+ECharts实现中国地图的绘制及各省份自动轮播高亮显示
2024-04-27 16:12:40
![](https://img.aspxhome.com/file/2023/0/132960_0s.gif)
php实现文章评论系统
2024-05-13 09:53:40
![](https://img.aspxhome.com/file/2023/9/126229_0s.png)
jRaiser与jQuery的冲突问题
2010-07-27 12:36:00
Python判断变量是否已经定义的方法
2023-08-01 07:14:01
大幅提升MySQL中InnoDB的全表扫描速度的方法
2024-01-19 20:58:42
![](https://img.aspxhome.com/file/2023/6/69836_0s.png)
MySQL系列之六 用户与授权
2024-01-28 05:37:31
openCV中值滤波和均值滤波的代码实现
2023-07-22 06:08:28
![](https://img.aspxhome.com/file/2023/9/134269_0s.jpg)
Python中celery的使用
2022-10-22 14:03:17
![](https://img.aspxhome.com/file/2023/8/124778_0s.jpg)
Python使用Web框架Flask开发项目
2021-07-08 20:08:56
pytorch 实现打印模型的参数值
2022-11-11 22:22:28
![](https://img.aspxhome.com/file/2023/5/99555_0s.jpg)
python的图形用户界面介绍
2023-04-08 19:55:46
![](https://img.aspxhome.com/file/2023/1/133281_0s.png)
windows中python实现自动化部署
2023-06-24 16:04:14
![](https://img.aspxhome.com/file/2023/0/134520_0s.jpg)
django框架使用方法详解
2021-07-07 18:12:00
![](https://img.aspxhome.com/file/2023/0/99590_0s.png)
Python实现ElGamal加密算法的示例代码
2023-05-23 15:25:58
浅析python中5个带key的内置函数
2021-08-27 00:31:25
Python HTTP客户端自定义Cookie实现实例
2023-12-16 01:19:30
Go GORM 事务详细介绍
2024-02-21 21:03:05
打包发布Python模块的方法详解
2021-04-03 06:10:56
Django 全局的static和templates的使用详解
2021-10-04 10:13:29
![](https://img.aspxhome.com/file/2023/4/99694_0s.png)
微信小程序实现简单倒计时功能
2024-04-17 10:23:27
![](https://img.aspxhome.com/file/2023/4/136304_0s.jpg)