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>
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>
<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>
可是点了按纽,怎么没有反应啊?
改正一下 ,改为cDialog.Filter="HTM Files (*.htm,*.html)|*.htm;*.html"
http://community.csdn.net/Expert/topic/3472/3472337.xml?temp=.1701624
着急啊!!!!!