ASP中不用模板生成HTML静态页面的方法


当然是可以的,而且非常简单,今天就教大家在ASP中不用模板生成HTML静态页的方法。

这里假设有一个htmer.asp动态页面,你想把它生成为HTML静态页面htmer.html,那么我们首先新建一个ASP程序文件htmer_to_html.asp(该文件就是用来将htmer.asp动态页面生成为静态页面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
%>

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3