<!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=gb2312" />
<title>无标题文档</title>
</head><body>
<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="loadDoc()"/>   
<input type="button" value="保存" onclick="saveDoc()"/>   
<script>   
function   loadDoc()   
{   
fileDialog.CancelError=true;   
        try{   
        fileDialog.Filter="HTM   Files   (*.htm)|*.htm|Text   Files   (*.txt)|*.txt";   
          fileDialog.ShowOpen();   
        var   fso=new   ActiveXObject("Scripting.FileSystemObject");   
        var   reading=1;   
        var   f=fso.OpenTextFile(fileDialog.filename,reading);   
        //window.confirm(f);   
        var   r=f.ReadAll();   
        f.close();   
        TxtBody.value=r;   
        }catch(e){}   
}   
function   saveDoc()   
{   
var content=document.getElementById("TxtBody").value;
alert(document.getElementById("TxtBody").value);
fileDialog.CancelError=true;   
        try{   
       fileDialog.Filter="HTM   Files   (*.htm)|*.htm|Text   Files   (*.ares)|*.ares";   
       fileDialog.ShowSave();  
       var fso=new   ActiveXObject("Scripting.FileSystemObject");  
       alert(fso);
       var f=fso.CreateTextFile("C:\Documents and Settings\Administrator\桌面\新建文件夹\1.txt",true);
      alert("ceshi");
       //alert(fileDialog.filename);
       //alert(document.getElementById("TxtBody").value);
       //alert(TxtBody.value); 
      //f.write(content);   
      f.Write ("This is a test.");
       f.Close();   
       }   
       catch(e){}   
}   
</script>   
</body>
</html>不能把textarea中的保存到由对话框指定的位置