ASP中不用模板生成HTML靜態(tài)頁面的方法
更新時間:2010年06月05日 14:05:29 作者:
我們一般生成HTML靜態(tài)頁時,常常會事先做好一個模板,然后生成時調(diào)用模板文件。那么有沒有辦法不用模板,如一個正常的htmer.asp頁面,直接生成為htmer.html頁面呢?
當然是可以的,而且非常簡單,今天就教大家在ASP中不用模板生成HTML靜態(tài)頁的方法。
這里假設(shè)有一個htmer.asp動態(tài)頁面,你想把它生成為HTML靜態(tài)頁面htmer.html,那么我們首先新建一個ASP程序文件htmer_to_html.asp(該文件就是用來將htmer.asp動態(tài)頁面生成為靜態(tài)頁面htmer.html的),htmer_to_html.asp的具體代碼如下所示:
<form method="post" action="">
<textarea name="asp2html" style="display:none"><!--#include file="htmer.asp"--></textarea>
<input type="submit" value="生成html頁"/>
</form>
<%
Dim Filename,Fso,Fout
If Request.Form("asp2html")<>"" Then
Filename="htmer.html"
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set Fout=Fso.CreateTextFile(Server.Mappath(Filename))
Fout.Write Request.Form("asp2html")
Fout.Close
Set Fout=Nothing
Set Fso=Nothing
End If
%>
這里假設(shè)有一個htmer.asp動態(tài)頁面,你想把它生成為HTML靜態(tài)頁面htmer.html,那么我們首先新建一個ASP程序文件htmer_to_html.asp(該文件就是用來將htmer.asp動態(tài)頁面生成為靜態(tài)頁面htmer.html的),htmer_to_html.asp的具體代碼如下所示:
復(fù)制代碼 代碼如下:
<form method="post" action="">
<textarea name="asp2html" style="display:none"><!--#include file="htmer.asp"--></textarea>
<input type="submit" value="生成html頁"/>
</form>
<%
Dim Filename,Fso,Fout
If Request.Form("asp2html")<>"" Then
Filename="htmer.html"
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set Fout=Fso.CreateTextFile(Server.Mappath(Filename))
Fout.Write Request.Form("asp2html")
Fout.Close
Set Fout=Nothing
Set Fso=Nothing
End If
%>
相關(guān)文章
ASP基礎(chǔ)入門第七篇(ASP內(nèi)建對象Response)
這篇文章主要介紹了ASP內(nèi)建對象Response的相關(guān)資料,需要的朋友可以參考下2015-10-10服務(wù)器XMLHTTP(Server XMLHTTP in ASP)基礎(chǔ)知識
幾年很流行 Ajax,而 Ajax 的本質(zhì)就是 XMLHttpRequest,是客戶端 XMLHttpRequest 對象的使用。2010-08-08asp實現(xiàn)生成由數(shù)字,大寫字母,小寫字母指定位數(shù)的隨機數(shù)
asp實現(xiàn)生成由數(shù)字,大寫字母,小寫字母指定位數(shù)的隨機數(shù)...2007-08-08ASP讀取Request.QueryString編碼的函數(shù)代碼
ASP讀取Request.QueryString編碼的函數(shù)代碼,學(xué)習(xí)asp的朋友可以參考下。2011-09-09ASP實現(xiàn)GB2312字符與區(qū)位碼的相互轉(zhuǎn)換的代碼
ASP實現(xiàn)GB2312字符與區(qū)位碼的相互轉(zhuǎn)換的代碼...2007-05-05