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

时间:2021-05-26

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

<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<title>hmtl页面</title>
</head>
<body>
alert(ok);
</body>
</html>

1楼
dimfileNameStr
fileNameStr=Trim(Request.Form("fileName"))
dimfileContentStr
fileContentStr=Trim(Request.Form("fileContent"))
Setfs=CreateObject("Scripting.FileSystemObject")
dimfilePath
filePath=Server.MapPath("PageURL/"&fileNameStr)
Seta=fs.CreateTextFile(filePath,True)
a.WriteLine(fileContentStr)
a.Close
2楼
在客户端实现保存的方法:
<textareaid=mmstyle="width:500"rows=8>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<title>hmtl页面</title>
</head>
<body>
alert(ok);
</body>
</html>
</textarea><br>
<inputtype=buttonvalue=saveonclick="Save()">
<SCRIPTLANGUAGE="JavaScript">
<!--
functionSave()
{
vartxt=document.all.mm;
varww=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>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章