-----058-FileSystemObject-文件.html-----
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>标题</title> </head> <body> <table> <caption><h3>以桌面为相对路径,然后:</h3></caption> <tr> <td><input type="text" id="input1"/></td> <td><button onclick="filename=base + get('input1').value; tf = fso.CreateTextFile(filename, true); tf.Close();">创建文件</button></td> <!-- 有则覆盖 --> </tr> <tr> <td><input type="text" id="input2"/></td> <td><button onclick="tf=fso.OpenTextFile(filename, 2, true); tf.Write(get('input2').value); tf.Close()">写入文件</button></td> </tr> <tr> <td><button onclick="tf=fso.OpenTextFile(filename, 1); get('lbl1').innerText=tf.ReadLine(); tf.Close()">读取文件</button></td> <td id="lbl1"></td> </tr> <!-- 1读2写8追加 --> </table> <script type="text/javascript"> var filename; var fso = new ActiveXObject("Scripting.FileSystemObject"); var base = "C:/USERS/BUTTON/DESKTOP/"; function get(el) { return document.getElementById(el); } </script> </body> </html>