javascript能不能打开一个保存文件的对话框 <button onclick='document.execCommand("saveAs")'>另存为...</button> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ice_berg16(寻梦的稻草人) 你这样是保存这个页面,我是想用户选择一个路径和文件名把数据保存到这个文件中 <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(){ 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> 单选路径:<input type=button value=选择路径 onclick="window.confirm(BrowseFolder())"><script>function BrowseFolder(){ var Message="请选择文件夹"; var Shell=new ActiveXObject("Shell.Application"); var Folder=Shell.BrowseForFolder(0,Message,0x0040,0x11); if(Folder!=null) { Folder=Folder.items();//返回FolderItems对象 Folder=Folder.item();//返回Folderitem对象 Folder=Folder.Path;//返回路径 if(Folder.charAt(Folder.length-1)!="\\") { Folder=Folder+"\\"; } return Folder; }}</script> 用FSO对象吧,不过会弹出安全提示窗口 请问Ext.Net 中的MultiCombo控件如何支持手动输入值? document.createElement 小问题 Jquery选择符$([])是什么意思 求js混淆和加缩器 这里的变量怎么表示? 表单提交的问题 js引用对象名称冲突的问题 求:取得前一天的日期 JS代码!(急) 图层中的图片被背景色覆盖了,是不是图层淡入淡出的问题了。帮忙看看吧。。。 简单问题,来抢分啊!!! 100分请高手帮忙,js加asp 页面的宽度和高度怎么获取?(请大家回答一下了,不要因为太简单)
</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()
{
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>
<input type=button value=选择路径 onclick="window.confirm(BrowseFolder())">
<script>
function BrowseFolder()
{
var Message="请选择文件夹";
var Shell=new ActiveXObject("Shell.Application");
var Folder=Shell.BrowseForFolder(0,Message,0x0040,0x11);
if(Folder!=null)
{
Folder=Folder.items();//返回FolderItems对象
Folder=Folder.item();//返回Folderitem对象
Folder=Folder.Path;//返回路径
if(Folder.charAt(Folder.length-1)!="\\")
{
Folder=Folder+"\\";
}
return Folder;
}
}
</script>