JavaScript文件读取问题
JavaScript能读相对路径中TXT文本信息吗?
如果能读
应该是这样的代码?
------解决方案--------------------可以
<script language= "javascript ">
function readfile(){
var fso,ts;
var ForReading;
fso=new ActiveXObject( "Scripring.FileSystemObject ");
ts=fso.OpenTextFile( "path ",ForReading,true);
ts.close();
}
</script>
------解决方案--------------------http://topic.csdn.net/t/20031128/17/2506668.html
------解决方案--------------------//读取txt文件
<html>
<head>
<title> new page </title>
<script>
function GetHeader(src) {
var ForReading=1;
var fso=new ActiveXObject( "Scripting.FileSystemObject ");
var f=fso.OpenTextFile(src,ForReading);
return(f.ReadAll());
}
var arr=GetHeader( "C:\\a.txt ").split( "\r\n ");
for(var i=0;i <arr.length;i++){
alert( "第 "+(i+1)+ "行数据为: "+arr[i]);
}
</script>
</head>
<body>
</body>
</html>
//c盘根目录放文件a.txt
aaaaaaaa
bbbbbbbb
cccccccc
dddddddd