1.cmd切换到“C:\Windows\System32>”下,执行“regsvr32 Scrrun.dll”

2.JavaScript读写txt文本代码如下,注意要发布到服务器上

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>读写txt文件</title>
 </head>
 <body>

 <script>
     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('写入txt数据成功!');
     }
     //读文件
     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;
     }
 </script>
 <input type="text" id="txtwrite" value="helloworld">
 <input type="button" value="Write!" onclick="writeFile('c://a.txt',document.getElementById('txtwrite').value)"/>
 <input type="button" value="Read!" onclick="document.getElementById('show').value=readFile('c:/a.txt')"/>
 <br>
 <textarea id="show" name="show" cols="30" rows="4" ></textarea>
 </body>
 </html>
05-08 15:03