<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>
</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>
解决方案 »
- 高分求一很简单的正则表达式
- 哪位老鸟能给个js代码
- 用javascript 拼接 网页select 标签,不起作用
- 火狐 js 表单提交 问题 在线等
- 求javascript类似delay的函数
- 怎么才能让用js脚本写的漂浮广告不被Flash遮住?
- javascript 中用Replace 替换的奇怪问题???
- 200分求教,把这段代码转换为vbs或jsp都可以?谢谢!在线等待
- 请教:HTML编辑器中的表格编辑
- 我想通过写函数的办法,使这个事件onblur="....." 不执行。请问怎么解决??
- 哪位大哥大姐帮忙看一下,怎么把这个JS优化一下,我写的太繁琐
- 如何設置<select>的第一個Option為選中狀態?急!!!
function onDownloadDone(s) {
content.value=s;
}
</SCRIPT>
<textarea name="content" cols=30 rows=20></textarea>
<IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<input type=file name='p'><input type=button value="open" onclick="oDownload.startDownload(p.value,
onDownloadDone)">
打开浏览器支持的图像格式<input type="file" name="myfile">
<input type="button" onclick="document.all.img.src=document.all.myfile.value"
value="Open">
<img name="img"/>