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

Javascript
我也种棵OO树JXTree[js+css+xml]
新浪中用来显示flash的函数
JXTree对象,读取外部xml文件数据,生成树的函数
用js来格式化字符串示例模仿css
js prototype 格式化数字 By shawl.qiu
新浪刚打开页面出来的全屏广告代码
记录几个javascript有关的小细节
Some tips of wmi scripting in jscript (1)
JavaScript Try...Catch 声明的 使用方法
JS版获取字符串真实长度和取固定长度的字符串函数
Javascript中的数学函数
ArrayList类(增强版)
javascript中巧用“闭包”实现程序的暂停执行功能
javascript判断单选框或复选框是否选中方法集锦
FireFox的getYear的注意事项
JavaScript For...In 使用方法
JavaScript Switch 声明
JavaScript If...Else 声明
JavaScript For 循环
JavaScript While 循环 教程

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 93 ::
收藏到网摘: 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>