选择显示字体大小

asp教程 - 实例演示:使用asp生成html文件 -

共有两个页面index.htm是首页.程序比较简单,主要是用了asp里的文件操作对象。

  <!--index.htm---------------------->

  <!doctype html public &quot;-//w3c//dtd html 4.01 transitional//en&quot;
  &quot;http://www.w3.org/tr/html4/loose.dtd&quot;>
  <html>
  <head>
  <title>untitled document</title>
  <meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=gb2312&quot;>
  </head>

  <body>
  <table width=&quot;770&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
  <tr>
    <td><form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;send.asp&quot;>
      <table width=&quot;100%&quot;  border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bgcolor=&quot;#ccffff&quot;>
        <tr>
          <td height=&quot;20&quot;><div align=&quot;center&quot;>发送消息</div></td>
          </tr>
        <tr>
          <td><div align=&quot;center&quot;>
            <textarea name=&quot;msg&quot; cols=&quot;100&quot; rows=&quot;6&quot;></textarea>
          </div></td>
          </tr>
        <tr>
          <td><div align=&quot;center&quot;>
              <input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;>
              <input type=&quot;reset&quot; name=&quot;submit2&quot; value=&quot;reset&quot;>
          </div></td>
          </tr>
      </table>
</form></td>
  </tr>
  </table>
  </body>
  </html>
  '//send.asp

  <%
  function chan_time(shijian)'转换日期时间函数
  s_year=year(shijian)
  if len(s_year)=2 then s_year=&quot;20&quot;&s_year
  s_month=month(shijian)
  if s_month<10 then s_month=&quot;0&quot;&s_month
  s_day=day(shijian)
  if s_day<10 then s_day=&quot;0&quot;&s_day
  s_hour=hour(shijian)
  if s_hour<10 then s_hour=&quot;0&quot;&s_hour
  s_minute=minute(shijian)
  if s_minute<10 then s_minute=&quot;0&quot;&s_minute
  chan_time=s_year & s_month & s_day & s_hour & s_minute
  end function

function chan_data(shijian)  '转换日期时间函数
  s_year=year(shijian)
  if len(s_year)=2 then s_year=&quot;20&quot;&s_year
  s_month=month(shijian)
  if s_month<10 then s_month=&quot;0&quot;&s_month
  s_day=day(shijian)
  if s_day<10 then s_day=&quot;0&quot;&s_day
  chan_data=s_year & s_month & s_day
end function

function chan_file(shijian)'转换日期时间函数
  s_month=month(shijian)
  if s_month<10 then s_month=&quot;0&quot;&s_month
  s_day=day(shijian)
  if s_day<10 then s_day=&quot;0&quot;&s_day
  s_hour=hour(shijian)
  if s_hour<10 then s_hour=&quot;0&quot;&s_hour
  s_minute=minute(shijian)
  if s_minute<10 then s_minute=&quot;0&quot;&s_minute
  s_ss=second(shijian)
  if s_ss<10 then s_ss=&quot;0&quot;&s_ss
  chan_file = s_month & s_day & s_hour & s_minute & s_ss
  end function
  top=&quot;<html><head><title>news</title></head><body>&quot;
  botom=&quot;</body></html>&quot;
  msg=request.form(&quot;msg&quot;)
  msg=replace(msg,vbcrlf,&quot;&quot;)
  msg=replace(msg,chr(9),&quot;&quot;)
  msg=replace(msg,&quot; &quot;,&quot;&nbsp;&quot;)
  msg=replace(msg,&quot;\r\n&quot;,&quot;<br>&quot;)
  msg=replace(msg,&quot;\n&quot;,&quot;<br>&quot;)
  msg=top&msg&botom
  set fs=server.createobject(&quot;scripting.filesystemobject&quot;)
  all_tree2=server.mappath(&quot;news&quot;)&&quot;\&quot;&chan_data(now)
  if (fs.folderexists(all_tree2)) then'判断今天的文件夹是否存在
  else
  fs.createfolder(all_tree2)
  end if   
  pass=chan_file(now)
  randomize  '使用系统计时器来初始化乱数产生器
  pass=rnd(pass)
  pass=get_pass(pass)
  pass=left(pass,10)
file1=pass
  files=file1&&quot;.txt&quot;
  filez=all_tree2&&quot;\&quot;&files

  set ts = fs.createtextfile(filez,true) '写文件
  for z=1 to len(msg)
   write_now=mid(msg,z,1)
   ts.write(write_now)
  next
' ts.writeline(all_msg)
  ts.close
  set ts=nothing    '文件生成

  if err.number<>0 or err then%>
   <script language=&quot;javascript&quot;>
   alert(&quot;不能完成&quot;)
   </script>
  <%else%>
   <script language=&quot;javascript&quot;>
  alert(&quot;已完成&quot;)
  history.back();
   </script>
  <%end if
  set myfile = fs.getfile(filez)
  all_tree2=server.mappath(&quot;news&quot;)&&quot;\&quot;&chan_data(now)
  if (fs.folderexists(all_tree2)) then
  else
  fs.createfolder(all_tree2)
  end if

myfile.name= left(myfile.name,len(myfile.name)-4)&&quot;.htm&quot;
  set myfile=nothing
  set fs=nothing
  set fdir=nothing
function get_pass(pass)

  pass=cstr(pass)
  pass=replace(pass,&quot; &quot;,&quot;&quot;)
  pass=replace(pass,&quot; &quot;,&quot;&quot;)
  pass=replace(pass,&quot;-&quot;,&quot;&quot;)
  pass=replace(pass,&quot; &quot;,&quot;&quot;)
  pass=replace(pass,&quot;:&quot;,&quot;&quot;)
  pass=replace(pass,&quot;.&quot;,&quot;&quot;)
  pass=replace(pass,&quot;+&quot;,&quot;&quot;)
  pass=replace(pass,&quot;_&quot;,&quot;&quot;)
  pass=replace(pass,&quot;<&quot;,&quot;&quot;)
  pass=replace(pass,&quot;>&quot;,&quot;&quot;)
  pass=replace(pass,&quot;!&quot;,&quot;&quot;)
  pass=replace(pass,&quot;@&quot;,&quot;&quot;)
  pass=replace(pass,&quot;#&quot;,&quot;&quot;)
  pass=replace(pass,&quot;$&quot;,&quot;&quot;)
  pass=replace(pass,&quot;%&quot;,&quot;&quot;)
  pass=replace(pass,&quot;^&quot;,&quot;&quot;)
  pass=replace(pass,&quot;&&quot;,&quot;&quot;)
  pass=replace(pass,&quot;*&quot;,&quot;&quot;)
  pass=replace(pass,&quot;(&quot;,&quot;&quot;)
  pass=replace(pass,&quot;)&quot;,&quot;&quot;)
  pass=replace(pass,&quot;=&quot;,&quot;&quot;)
  pass=replace(pass,&quot;\&quot;,&quot;&quot;)
  pass=replace(pass,&quot;/&quot;,&quot;&quot;)
  pass=replace(pass,&quot;&quot;,&quot;&quot;)
  get_pass=pass

  end function

  %>

  '//

  把send.asp和index.htm放到你的asp目录下,然后再建一个news文件夹。打开浏览器,在地址栏里输入:http://你的机器名/你的asp虚拟目录名/index.html输入文字,然后提交,ok!看看你的asp目录里新建的news文件夹里是不是多了个新的文件夹,而且是以当前日期命名的。里面有你刚刚提交的文字,看看是不是生成了html文件。怎么样,你可以在此基础上做个简单的新闻发布系统。。



 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons