1.使用CommandDialog作为选择对话框
2.使用FSO对象来写文件<OBJECT id=cDialog codeBase=http://activex.microsoft.com/controls/vb5/comdlg32.cab
 height=0px width=0px classid=CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB></OBJECT>
<SCRIPT language=javascript>
function SaveDocument(){
   cDialog.CancelError=true;
   try{
   cDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt"
   cDialog.ShowSave();
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   var f = fso.CreateTextFile(cDialog.filename,  true);
   f.write(document.body.innerHTML);
   f.Close();
   sPersistValue=document.body.innerHTML;}
   catch(e){
   var sCancel="true";
   return sCancel;}
  }</SCRIPT><BUTTON onclick=SaveDocument();>保存</BUTTON>

解决方案 »

  1.   

    将上面的 cDialog.Filter改为你自己需要的 cDialog.Filter="HTM Files (*.htm,*.html)|*.htm,*.html"
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/xml; charset=gb2312">
    <OBJECT id=cDialog codeBase=http://activex.microsoft.com/controls/vb5/comdlg32.cab
     height=0px width=0px classid=CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB VIEWASTEXT></OBJECT><script language="JavaScript">
    function save()
    {
       
    cDialog.CancelError=true;
       try{
       cDialog.Filter="HTM Files (*.htm)|*.htm|Text Files (*.txt)|*.txt"
       cDialog.ShowSave();
       var fso = new ActiveXObject("Scripting.FileSystemObject");
       var f = fso.CreateTextFile(cDialog.filename,  true);
       f.write(document.body.innerHTML);
       f.Close();
       sPersistValue=document.body.innerHTML;}
       catch(e){
       var sCancel="true";
       return sCancel;}
    }
    </script>
    </head><body><input type="button" name="Button" value="Button" onClick="save()" ID="Button1">
    </body>
    可是点了按纽,怎么没有反应啊?
      

  3.   

    没反应?不会吧cDialog.Filter="HTM Files (*.htm,*.html)|*.htm,*.html"
    改正一下 ,改为cDialog.Filter="HTM Files (*.htm,*.html)|*.htm;*.html"
      

  4.   

    <--------------高手看过来! 能不能搞定这个?
    http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.1701624
      

  5.   

    请问 juwuyi(我有,我可以) ,是否我写的位置不对?还是要进行什么设置啊?
    着急啊!!!!!