当前位置: 代码网 > it编程>编程语言>其他编程 > 如何用ASP输出HTML文件?

如何用ASP输出HTML文件?

2024年05月15日 其他编程 我要评论
<!--#include file="top.inc"--><%u_title=request.form("u_title")' 检查标题是否被输入.if u_title = ""

<!--#include file="top.inc"-->
<%
u_title=request.form("u_title")

' 检查标题是否被输入.
if u_title = "" then
%>
<form method="post" action="<%= request.servervariables("script_name") %>">
 <!--
当没有标题输入时显示输入框-->

  <p>
文件标题<br>
  <input type="text" name="u_title" size="35"></p>
  <p>font size<br>
  <select size="1" name="u_text_size">
  <option selected value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  &nbsp;
  </select></p>
  <p>
1<br>
  <textarea rows="2" name="u_paragraph1" cols="35"></textarea></p>
  <p>
2<br>
  <textarea rows="2" name="u_paragraph2" cols="35"></textarea><input type="submit" value="
提交" ></p>
</form>
<%
end if
%>

<%
if u_title <> "" then
    u_title=request.form("u_title")
    u_paragraph1=request.form("u_paragraph1")
    u_paragraph2=request.form("u_paragraph2")
    u_text_color=request.form("u_text_color")
    u_text_size=request.form("u_text_size")
    g_filename=replace(u_title," ","_")

' 如果有一个用户输入了标题,则获取所有的用户输入的内容.

set fso = createobject("scripting.filesystemobject")
set act = fso.createtextfile(server.mappath("write2htm/"&g_filename & "-"& month(date())& day(date())& year(date()) &".htm"), true)
创建create the text (html) file文件到服务器,并添加mmddyyyy 格式年月日.

写所有用户输入的text (html) 文件, .htm 扩展名文件可以很容易地转换成你网站最需要的.asp .inc文件.
    act.writeline "<html>"
    act.writeline chr(13)
    act.writeline "<title>"& u_title &"</title>"
    act.writeline chr(13)
    act.writeline "<body bgcolor='#ffffff'>"
    act.writeline chr(13)
    act.writeline "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    act.writeline chr(13)
    act.writeline  u_title &"</p>"
    act.writeline chr(13)
    act.writeline "<p align='left'><font face='arial' size='"&u_text_size&"'>"
    act.writeline chr(13)
    act.writeline  u_paragraph1 &"</p>"
    act.writeline chr(13)
    act.writeline "<p align='left'><font face='arial' size='"& u_text_size &"'>"
    act.writeline chr(13)
    act.writeline u_paragraph2 &"</p>"
    act.writeline chr(13)
    act.writeline "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
    act.writeline "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    act.writeline "
此文件被创建!"
    act.writeline  now() &"</p>"
act.close

' 关闭文件.
%>
您的页面已成功创建!请点击查看.
<a href="write2htm/<%= g_filename &"-"& month(date())& day(date())& year(date())  %>.htm"
target="_blank">
查看</a>
<br>
<br>
<% response.write "<html>"
    response.write chr(13)
    response.write "<title>"& u_title &"</title>"
    response.write chr(13)
    response.write "<body bgcolor='#ffffff'>"
    response.write chr(13)
    response.write "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    response.write chr(13)
    response.write  u_title &"</p>"
    response.write chr(13)
    response.write "<p align='left'><font face='arial' size='"&u_text_size&"'>"
    response.write chr(13)
    response.write  u_paragraph1 &"</p>"
    response.write chr(13)
    response.write "<p align='left'><font face='arial' size='"& u_text_size &"'>"
    response.write chr(13)
    response.write u_paragraph2 &"</p>"
    response.write chr(13)
    response.write "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
    response.write "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    response.write "
此文件被创建!"
    response.write  now() &"</p>"
end if
%>
<!--#include file="bottom.inc"-->

 

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com