script是不能进行这类操作的。

解决方案 »

  1.   

    <object id="fileDialog" width="0px" height="0px" classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB" codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">
    </object>
    <textarea id=TxtBody style="background-color:#EEEEEE;width:100%;height:100">无标题</textarea>
    <br>
    <input type=button value=保存 onclick="saveDoc()">
    <script>
    function saveDoc()
    {
    fileDialog.CancelError=true;
       try{
       fileDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt";
       fileDialog.ShowSave();
       var fso=new ActiveXObject("Scripting.FileSystemObject");
       var f=fso.CreateTextFile(fileDialog.filename,true);
       f.write(TxtBody.value);
       f.Close();
       }
       catch(e){}
    }
    </script>
    </body>
      

  2.   

    demo.asp '有个提示下载文件.<!--#include file="conn.asp"-->
    <%
    Dim FileName
    Const adTypeBinary = 1
    FileName = "data.txt"
    Response.Clear
    Response.ContentType = "application/octet-stream"
    Response.AddHeader "content-disposition", "attachment; filename=" & FileName
    '服务器数据库上取得数据
    set rs=server.CreateObject("adodb.recordset")
    sql="select * from web"
    rs.open sql,conn,1,1
    do while not rs.eof
    Response.Write rs("webname")
    rs.movenext
    loop
    rs.close
    set rs=nothing
    %>   
      

  3.   

    function save(){
    var folder = new ActiveXObject("Scripting.FileSystemObject");
    var f = folder.createtextfile(abc.xml,"true");//将.xml改为.txt即可保存为.txt文件
    f.WriteLine("<?xml version='1.0' encoding='gb2312'?>");
    f.WriteLine("<SCHEMA  CHSNAME='"+document.nasuiren.CHSNAME.value+"'"+" NAME='ZZSZB'"+" SBSQ='"+document.nasuiren.SBSQ.value+"'>");
      f.WriteLine("<TAXPAYER  NSRMC='"+document.nasuiren.NSRMC.value+"'"+" SCRQ='"+document.nasuiren.SCRQ.value+"'"+" SWSBH='340202149384153' >")
      f.WriteLine("</TAXPAYER>")
      f.WriteLine("<Records>")
       f.WriteLine("<sbbl1>"+document.nasuiren.sbbl1.value+"</sbbl1>")  
      f.WriteLine("</Records>")
    f.WriteLine("</Records>")
    f.WriteLine("</SCHEMA>");
    f.Close();
    }
      

  4.   

    ruangaofeng(高峰) 
    为什么说abc未定义啊?
      

  5.   

    abc.xml是你要保存到本地磁盘的文件名,把扩展名.xml改为.txt就是你想要的文本文件
    abc只不过是文件名,你随便写。
    简单点就这样
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var a = fso.CreateTextFile("c:\\fileName.txt", true);
    a.WriteLine("This is a test.");
    a.Close();
      

  6.   

    ruangaofeng(高峰) 
    还是有错误提示:document.nasuiren.CHSNAME不是对象
      

  7.   

    document.nasuiren.CHSNAME只是我给你示例
    document是个文本对象。一个.htm网页就是一个document
    nasuiren是form的name名
    例如:
    <form   name="nasuiren" method="post">
    CHSNAME是file的name名
    例如:
    <input type="file" name="CHSNAME">
    这样的好处就是文件名可以是用户定!
      

  8.   

    ruangaofeng(高峰) 
    Thanks!!