怎么利用js读取txt文件

xiaoxiao2021-02-28  28

js读取txt文件:

1 2 3 4 5 6 7 8 9 function  readFile(filename){ var  fso =  new  ActiveXObject( "Scripting.FileSystemObject" ); var  f = fso.OpenTextFile(filename,1); var  s =  "" ; while  (!f.AtEndOfStream) s += f.ReadLine()+ "\n" ; f.Close(); return  s; }

js写txt文件:

1 2 3 4 5 6 7 8 function  writeFile(filename,filecontent){ var  fso, f, s ; fso =  new  ActiveXObject( "Scripting.FileSystemObject" ); f = fso.OpenTextFile(filename,8, true ); f.WriteLine(filecontent); f.Close(); alert( 'ok' ); }
转载请注明原文地址: https://www.6miu.com/read-1700026.html

最新回复(0)