ASP生成静态html
录入的内容,自动生成html文件.
演示地址
<%
filename=year(now)&month(now)&day(now)&minute(now)&".htm" '根据当前时间生成文件名
if request("body")<>"" then
set objfso = Server.CreateObject("Scripting.FileSystemObject") '创建一个fso实例
set htmout = objfso.CreateTextFile(server.mappath(""&filename&""))
htmout.write "<html><head><title>"
htmout.write request.form("title")
htmout.write "</title></head><body>新闻标题:"
htmout.write request.form("title")
htmout.write "<br>内容(body):"
htmout.write request.form("body")
htmout.write "</body></html>"
htmout.close
set htmout=nothing
set objfso=nothing
end if
%>
<form name="form1" method="post" action="">
<table width="300" border="0" align="center">
<tr>
<td align="right">标题:</td>
<td colspan="2"><input name="title" size=18></td>
</tr>
<tr>
<td align="right">内容:</td>
<td colspan="2"><textarea name="body"></textarea></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="submit" name="Submit" value="生成"></td>
<td><a href="<%=filename%>" target="_blank">查看输出的文件</a></td>
</tr>
</table>
<br>
<br>
<br>
</form>