textarea的value是html文件源代碼,存成html文件的代碼
更新時(shí)間:2007年04月20日 00:00:00 作者:
textarea的value是html文件源代碼,如何把源代碼存成html文件??
如
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hmtl頁(yè)面</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樓
在客戶端實(shí)現(xiàn)保存的方法:
<textarea id=mm style="width: 500" rows=8>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hmtl頁(yè)面</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>
如
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hmtl頁(yè)面</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樓
在客戶端實(shí)現(xiàn)保存的方法:
<textarea id=mm style="width: 500" rows=8>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>hmtl頁(yè)面</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>
相關(guān)文章
通過(guò)ifame指向的頁(yè)面高度調(diào)整iframe的高度
[紅色]通過(guò)ifame指向的頁(yè)面高度調(diào)整iframe的高度...2006-10-10
google 搜索框添加關(guān)鍵字實(shí)現(xiàn)代碼
一段創(chuàng)新的搜索腳本代碼來(lái)自tourbus的Bob Rankin提供了一段定制的JAVA代碼.2010-04-04
使用button標(biāo)簽,實(shí)現(xiàn)三態(tài)圖片按鈕
使用button標(biāo)簽,實(shí)現(xiàn)三態(tài)圖片按鈕...2007-01-01
javascript在一段文字中的光標(biāo)處插入其他文字
javascript在一段文字中的光標(biāo)處插入其他文字...2007-08-08
用javascript來(lái)實(shí)現(xiàn)select標(biāo)簽的美化的代碼
用javascript來(lái)實(shí)現(xiàn)select標(biāo)簽的美化的代碼...2007-10-10

