3种可能:
1.在运行里面执行regsvr32 scrrun.dll,如果不行,继续;
2.安装msxml3.dll,再不行,还继续
3.在internet选项里"安全"选项卡中涉及到activex的都启用,安全级别设置为 中.再不行,我也没招了.

解决方案 »

  1.   

    用你这种方式当然会被浏览器的安全机制毙掉!<input type=button value=保存     onclick="document.execCommand('SaveAs')" />
    <input type=button value=另存为   onclick="document.execCommand('Saveas',false,'c:\\test.htm')" />
      

  2.   

    TO:meizz(梅花雪)使用你的方法是把页面另存为HTML,我需要的是输出我指定的文件内容,而且是Javascript生成的!
      

  3.   

    那就用FileSystemObject写你想写的内容啊。
      

  4.   

    TO:chouchy(城市刀客)用FileSystemObject可以写文件的内容,但是如何打开“保存文件”对话框呢?
    我还需要通知用户选择保存文件路径和文件名
      

  5.   

    TO:liqiang8() 1.在运行里面执行regsvr32 scrrun.dll,如果不行,继续;
    ------------
    试过,失败^_^2.安装msxml3.dll,再不行,还继续
    ------------
    安装就有3.在internet选项里"安全"选项卡中涉及到activex的都启用,安全级别设置为 中.再不行,我也没招了.
    ------------
    安全级别:低,所有都许可了
    ==========================================================
    另外大家知道“Automation server can't create object”错误的原因有哪些么?
      

  6.   

    梅花雪的思路可以实现LZ所需的效果,因为我也有用过,如保存EXCEL文件
      

  7.   

    TO:BookSirSwordsMan(书生剑客) 梅花雪的思路 document.execCommand('Saveas',false,'c:\\test.htm') 保存的好像是页面,我如何控制输出文件的格式和内容呢?
      

  8.   

    asp.jscript<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    <!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>shawl.qiu template</title>
    </head>
    <body>
    <%
     Download("id", "file", "/upload/", false);
     
     function Download(QueryId, FilePath, pathForCheck, Debug)
     {
      var Debug = false;
      
      var QueryId = Request.QueryString(QueryId)+"";
      var FilePath = Request.QueryString(FilePath)+"";
      
      if(Debug)
      {
       Response.Write("<li/>typeof(QueryId): "+typeof(QueryId));
       Response.Write("<li/>QueryId: "+QueryId);
       Response.Write("<li/>QueryId==\"\": "+(QueryId==""));
       Response.Write("<li/>QueryId==\"undefined\": "+(QueryId=="undefined"));
       Response.Write("<hr/>"); 
       
       Response.Write("<li/>typeof(FilePath): "+typeof(FilePath));
       Response.Write("<li/>FilePath: "+FilePath);
       Response.Write("<li/>FilePath==\"\": "+(FilePath==""));
       Response.Write("<li/>FilePath==\"undefined\": "+(FilePath=="undefined"));
       Response.Write("<hr/>"); 
      }
       
      if(QueryId=="undefined"||FilePath=="undefined")Response.End();
      
      switch(QueryId)
      {
       case "download":
        if(Debug)
        {
         Response.Write("<li/>download: ");
         Response.Write("<hr/>");
        }
        if(!CheckPathIn(FilePath, pathForCheck, true, Debug))Response.End();
        DownloadFile(FilePath, true);
        break;
      }
       
      function CheckPathIn(path, pathForCheck, bCovPath, Debug)
      {
       if(bCovPath)
       {
        path=Server.MapPath(path);
        pathForCheck=Server.MapPath(pathForCheck);
       } // end if
       
       if(Debug)
       {
        Response.Write("<li/>path: "+path);
        Response.Write("<li/>pathForCheck: "+pathForCheck);
       }
       
       if(path.indexOf(pathForCheck)<0)return false;
       return true;
      }
      
      function DownloadFile(sFilePath, bCovPath, Debug)
      {
       if(sFilePath=="")return;
       if(bCovPath)sFilePath=Server.MapPath(sFilePath);
       
       if(Debug)
       {
        Response.Write("<li/>download debug:");
        Response.Write("<li/>sFilePath: "+sFilePath);
        Response.End();
       }
       
       if(!fFlCkFl(sFilePath))return;
       
       var fileName = sFilePath.replace(/.*\\/,"");
       Response.Clear();
       
       Response.ContentType="application/octet-stream";
       Response.AddHeader("Content-Disposition","attachment;filename="+fileName);
       
       Response.BinaryWrite(fReadBinaryFromFile(sFilePath));
       
       Response.Flush();
       Response.End();
       
       function fFlCkFl(sPath){
        return new ActiveXObject("scripting.fileSystemObject").FileExists(sPath);
       }
       
       function fReadBinaryFromFile(sPath, sCharset){
        var o=new ActiveXObject('adodb.stream')
         with(o){
          Type=1;
          Mode=3;
          Open();
          LoadFromFile(sPath);
          var pNum=0
          if(typeof sCharset!='undefined'&&sCharset!=''){
           CharSet=sCharset;
           if(sCharset=='utf-8'||sCharset=='unicode')pNum=2;
          }
          Position=pNum;
          var $str=Read();
          close();
         }
        o=null;
        return $str; 
       } // end function fReadBinaryFromFile(sPath, sCharset) // shawl.qiu code
      } // end function DownloadFile // shawl.qiu code
     } // end function Download
    %>
    </body>
    </html>
      

  9.   

    你可以先 var win = window.open(); 然后再 win.document.write(str), 把你的内容写到这个新开窗口中,然后再 win.document.execCommand('Saveas',false,'c:\\test.htm'), 最后 win.close() 关掉这个临时窗口。
      

  10.   

    TO: meizz(梅花雪) 非常感谢,提供了很好的思路!等待接分