textarea的value是html文件源代碼,存成html文件的代碼
更新時間:2007年04月20日 00:00:00 作者:
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樓
在客戶端實現(xiàn)保存的方法:
<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>
如
<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樓
在客戶端實現(xiàn)保存的方法:
<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>
相關文章
Javascript 文本框textarea高度隨內容自適應增長收縮
之前一段時間項目中用到的一個功能,用Javascript控制文本框textarea高度隨內容自適應增長收縮,今天花了點時間換了種實現(xiàn)方法,總結一下。2011-07-07javascript中input中readonly和disabled區(qū)別介紹
javascript中input中readonly和disabled區(qū)別,在開發(fā)中可能會常有用到,利用js動態(tài)改變input的屬性2012-10-10js實現(xiàn)的的 文字自動''到google search框
js實現(xiàn)的的 文字自動''到google search框...2007-05-05同一個表單 根據(jù)要求遞交到不同頁面的實現(xiàn)方法小結
同一個表單 根據(jù)要求遞交到不同頁面的實現(xiàn)方法,就是好多網(wǎng)站,可以百度一個表單可以搜索音樂,圖片等2009-08-08使用button標簽,實現(xiàn)三態(tài)圖片按鈕
使用button標簽,實現(xiàn)三態(tài)圖片按鈕...2007-01-01