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樓
在客戶(hù)端實(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樓
在客戶(hù)端實(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)文章
Javascript 文本框textarea高度隨內(nèi)容自適應(yīng)增長(zhǎng)收縮
之前一段時(shí)間項(xiàng)目中用到的一個(gè)功能,用Javascript控制文本框textarea高度隨內(nèi)容自適應(yīng)增長(zhǎng)收縮,今天花了點(diǎn)時(shí)間換了種實(shí)現(xiàn)方法,總結(jié)一下。2011-07-07javascript中input中readonly和disabled區(qū)別介紹
javascript中input中readonly和disabled區(qū)別,在開(kāi)發(fā)中可能會(huì)常有用到,利用js動(dòng)態(tài)改變input的屬性2012-10-10Js密碼強(qiáng)度實(shí)時(shí)驗(yàn)證代碼
這款密碼強(qiáng)度實(shí)時(shí)驗(yàn)證代碼比較實(shí)用啊, 也比較簡(jiǎn)單,通過(guò)對(duì)輸入字符串的判斷,得知密碼的強(qiáng)度。2010-06-06js實(shí)現(xiàn)的的 文字自動(dòng)''到google search框
js實(shí)現(xiàn)的的 文字自動(dòng)''到google search框...2007-05-05同一個(gè)表單 根據(jù)要求遞交到不同頁(yè)面的實(shí)現(xiàn)方法小結(jié)
同一個(gè)表單 根據(jù)要求遞交到不同頁(yè)面的實(shí)現(xiàn)方法,就是好多網(wǎng)站,可以百度一個(gè)表單可以搜索音樂(lè),圖片等2009-08-08使用button標(biāo)簽,實(shí)現(xiàn)三態(tài)圖片按鈕
使用button標(biāo)簽,實(shí)現(xiàn)三態(tài)圖片按鈕...2007-01-01沒(méi)有form表單情況下敲回車(chē)鍵提交表單的js代碼
原來(lái)文章是jsp下,其實(shí)應(yīng)用了js的代碼,大家可以參考下,其實(shí)各個(gè)語(yǔ)言的原理都一樣,如果使用了ajax嚴(yán)重就完美的客戶(hù)端驗(yàn)證了。2009-09-09