当前位置: 首页 > 图文教程 > 网络编程 > Javascript > textarea的value是html文件源代码,存成html文件的代码

Javascript
JavaScript实现Sleep函数的代码
一个可以显示阴历的JS代码
从csdn弄下来的页面预先载入效果
键盘事件中keyCode、which和charCode 的兼容性测试
一个支持ff的modaldialog的js代码
[js+css]点击隐藏层,点击另外层不能隐藏原层
用javascript实现页面打印的三种方法
HTML-CSS群中单选引发的“事件”
一款不错的键盘密码输入js程序
限制文本字节数js代码
静态图片的十一种滤镜效果--不支持Ie7及非IE浏览器。
用javascript动态调整iframe高度的方法
用一段js程序来实现动画功能
javascript实现划词标记+划词搜索功能
javascript 简单高效判断数据类型 系列函数 By shawl.qiu
服务端 VBScript 与 JScript 几个相同特性的写法 By shawl.qiu
禁止F5等快捷键的JS代码
在textarea文本域中显示HTML代码的方法
Javascript之文件操作
修改发贴的编辑功能

Javascript 中的 textarea的value是html文件源代码,存成html文件的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 145 ::
收藏到网摘: n/a

textarea的value是html文件源代码,如何把源代码存成html文件??

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hmtl页面</title>
</head>
<body>
alert(ok);
</body>
</html>
1楼
dim fileNameStr
fileNameStr = Trim(Request.Form("fileName"))
dim fileContentStr
fileContentStr = Trim(Request.Form("fileContent"))
Set fs = CreateObject("Scripting.FileSystemObject")
dim filePath
filePath = Server.MapPath("PageURL/" & fileNameStr)
Set a = fs.CreateTextFile(filePath, True)
a.WriteLine(fileContentStr)
a.Close
2楼
在客户端实现保存的方法:
<textarea id=mm style="width: 500" rows=8>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hmtl页面</title>
</head>
<body>
alert(ok);
</body>
</html>
</textarea><br>
<input type=button value=save onclick="Save()">
<SCRIPT LANGUAGE="JavaScript">
<!--
function Save()
{
var txt = document.all.mm;
var ww = window.open("", "_blank", "width=100px, height=100px");
ww.document.write(txt.value);
ww.document.close();
ww.document.execCommand('SaveAs');
//ww.document.execCommand('Saveas',false,'c:\\test.htm');
ww.close();
}
//-->
</SCRIPT>