<!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中的保存到由对话框指定的位置
<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中的保存到由对话框指定的位置
解决方案 »
- js中{}的使用
- javascript代码修改, 单击不同的div,实现<select></select>下拉列表框中选中内容的切换。取出他的id作为索引。
- swfObject.embedSWF 求高手解决下下面的js问题 路径
- try catch的疑问
- 网站收藏的问题
- 如何实现一个拖动层可以跟随屏幕移动
- javascript做的页面刷新问题,高手请进,顶者有分
- dojo如何实现省份地市级联
- 请教 在多个网页中多次引用到一个JAVASCRIPT函数,怎么帮这个函数存成*.JS格式,怎么调用这个函数
- jquery 谷歌报错:Syntax error, unrecognized expression: )))
- 有谁知道 淘宝的数据魔方前台应用的什么技术!
- 急!!!dwr框架做的ajax点击无反应!!
否则JS的破坏性太大
由此看来使用这种办法不太好,我得重新考虑使用别的办法