| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 642 人关注过本帖
标题:关于生成html。
只看楼主 加入收藏
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
结帖率:0
收藏
 问题点数:0 回复次数:4 
关于生成html。

这是一个生成html的方法 makehtml.asp <% Option Explicit '随机码 function rndn() dim rndnum randomize rndnum=rnd*99+1 rndn=int(rndnum) end function '转换日期(年份) function chuageyear(shijian) dim s_year s_year=year(shijian) chuageyear=s_year end function

'转换日期(月份) function chuagemonth(shijian) dim s_month s_month=month(shijian) chuagemonth=s_month end function

'时间文件名(日期+随机码) function filename(shijian,rndmun) dim s_day,s_hour,s_min,s_sec,filen s_day=day(shijian) if s_day<10 then s_day="0"&s_day s_hour=hour(shijian) if s_hour<10 then s_hour="0"&s_hour s_min=minute(shijian) if s_min<10 then s_min="0"&s_min s_sec=second(shijian) if s_sec<10 then s_sec="0"&s_sec filen=s_day&s_hour&s_min&s_min&s_sec&rndmun filename=filen end function

'生成文件夹 function cfolder(times,pathname) dim fs set fs=server.createobject("Scripting.FileSystemObject") dim makeyear,makemonth,path path=pathname makeyear=server.mappath(path)&"\"&chuageyear(times) 'response.Write( makeyear) 'response.Write( not fs.FolderExists(makeyear)) 'response.Write(chuageyear(times)) 'response.End() if not fs.FolderExists(makeyear) then fs.CreateFolder(makeyear) '建立年份新文件夹 makemonth=makeyear&"\"&chuagemonth(times) if not fs.FolderExists(makemonth) then fs.createfolder(makemonth) '建立月份文件夹 cfolder=makemonth set fs=nothing end function

'生成html function makehtml(nowtime,body,pathname,rndnum) 'nowtime 文件的时间 'body 内容 'pathname 目录 文件夹 'rndnum 随机码 '以上可以从数据库读。 dim htmlname,txtname,write_one,filepath,fs,filez,isok,st,i,myfile isok=1 set fs=server.createobject("Scripting.FileSystemObject") htmlname=filename(nowtime,rndnum) txtname=htmlname&".txt" filez=cfolder(nowtime,pathname)&"\"&txtname '生成.txt 'response.Write(filez) 'response.End() set st=fs.createtextfile(filez,true) for i=1 to len(body) write_one=mid(body,i,1) st.write(write_one) next st.close set st=nothing if err.number<>0 then '有错误发生时! isok=0:err.clear:exit function end if 'filepath=cfolder(nowtime,pathname) 'filepath=filepath&txtname Set MyFile = fs.GetFile(filez) 'response.Write(len(filez)-4) 'response.Write( left(filez,(len(filez)-4))&".htm") 'response.End() MyFile.name=left(MyFile.name,len(MyFile.name)-4)&".htm" if err.number<>0 then '更改后缀名有错误时 '删除.txt文件 fs.delectfile(filepath) isok=0:err.clear:exit function end if set myfile=nothing 'fs.close set fs=nothing makehtml=isok end function %> 测试页面: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="../inc/makehtml.asp"--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> </head>

<body> <% dim rndm,path,nows,body rndm=rndn() path="test" nows=now() body="abasdfsdfasdfadfsd" if makehtml(nows,body,path,rndm)=0 then response.Write("生成失败") else response.Write("生成成功") end if %> </body> </html> 我测试通过,有问题可以联系我!

搜索更多相关主题的帖子: html 
2005-07-12 10:24
布什他爷爷
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2005-7-10
收藏
得分:0 
function filename(shijian,rndmun) dim s_day,s_hour,s_min,s_sec,filen s_day=day(shijian) if s_day<10 then s_day="0"&s_day s_hour=hour(shijian) if s_hour<10 then s_hour="0"&s_hour s_min=minute(shijian) if s_min<10 then s_min="0"&s_min s_sec=second(shijian) if s_sec<10 then s_sec="0"&s_sec filen=s_day&s_hour&s_min&s_min&s_sec&rndmun filename=filen end function
请问一下高手,functio里面的 if then要end if 结束吗.
2005-07-12 10:59
盖茨他爹
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:5255
专家分:0
注 册:2005-5-3
收藏
得分:0 
当然要结束
这不是废话吗
2005-07-12 11:07
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 
if ...then...在一行的话,就不用end if

59ita点com(我就爱TA)
2005-07-12 11:18
ASP菜菜菜鸟
Rank: 1
等 级:新手上路
帖 子:290
专家分:0
注 册:2005-5-8
收藏
得分:0 
以下是引用盖茨他爹在2005-7-12 11:07:43的发言: 当然要结束 这不是废话吗
好像不用结束,

总有一天,我要亲手打布什一吧掌.
2005-07-12 17:15
快速回复:关于生成html。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020775 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved