• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

asp生成html文件函数代码及演示示例

实用代码 开心洋葱 2131次浏览 0个评论

asp 生成html文件函数代码及演示示例


'函数参数说明
'mulu 实际生成的文件目录
'htmlmulu htmlmulu文件URL目录
'FileName html生成的文件名
'filefrom 要读取的(生成的)asp动态文件
'htmla,htmlb,htmlc,htmld 备用的参数

Function htmll(mulu,htmlmulu,FileName,filefrom,htmla,htmlb,htmlc,htmld)
if mulu="" then mulu=""&HtmlDir&""
if htmlmulu="" then htmlmulu=""&SysRootDir&""
mulu=replace(mulu, "//", "/")
FilePath=Server.MapPath(mulu)&"\"&FileName
Do_Url="http://"
Do_Url=Do_Url&Request.ServerVariables("server_name")&"/asp"&htmlmulu&filefrom
Do_Url=Do_Url&"?"&htmla&htmlb&"&"&htmlc&htmld
strUrl=Do_Url
set objXmlHttp=Server.createObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
binFileData=objXmlHttp.responseBody
Set objXmlHttp=Nothing
set objAdoStream=Server.CreateObject("Adodb." & "Stream")
objAdoStream.Type=1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
set objAdoStream=nothing
End Function

ASP生成伪静态HTML SHTML文件函数使用实例:

Sub HtmlProSort
totalrec=Conn.Execute("Select count(*) from Qianbo_Products Where ViewFlag")(0)
totalpage=int(totalrec/ProInfo)
If (totalpage * ProInfo)<totalrec Then
totalpage=totalpage+1
End If
if totalpage<=1 then
call htmll("","",""&ProSortName&"."&HTMLName&"","ProductList.asp","Page=",1,"","")
else
for i=1 to totalpage
call htmll("","",""&ProSortName&""&Separated&""&i&"."&HTMLName&"","ProductList.asp","Page=",i,"","")
next
end if
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from Qianbo_ProductSort order by ID desc"
rs.open sql,conn,1,1
If rs.eof Then
 Class_Num=0
Else
 Class_Num=1
do while not rs.eof
ID=rs("ID")
SortPath=conn.execute("select * from Qianbo_ProductSort Where ViewFlag And ID="&ID)("SortPath")
totalrec=Conn.Execute("Select count(*) from Qianbo_Products where ViewFlag and SortPath Like '%"&SortPath&"%'")(0)
totalpage=int(totalrec/ProInfo)
If (totalpage * ProInfo)<totalrec Then
totalpage=totalpage+1
End If
if totalpage<=1 then
call htmll("","",""&ProSortName&""&Separated&""&ID&""&Separated&"1."&HTMLName&"","ProductList.asp","SortID=",ID,"Page=",1)
else
for i=1 to totalpage
call htmll("","",""&ProSortName&""&Separated&""&ID&""&Separated&""&i&"."&HTMLName&"","ProductList.asp","SortID=",ID,"Page=",i)
next
end If
Response.Write "<script>bar_img.width="&Fix((Class_Num/rs.recordcount)*300)&";"
Response.Write "bar_txt1.innerHTML=""成功生成"&Class_Num&"个分类的HTML静态页面。完成比例:" & formatnumber(Class_Num/rs.recordcount*100) & """;</script>"
Response.Flush
rs.movenext
Class_Num=Class_Num+1
Loop
End If
rs.close
set rs=nothing
End Sub

代码是以函数出现可以在其他地方调用,并且数据时是以连接数据库读取出来,更适合使用和理解

asp 生成html文件函数代码及演示示例


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明asp生成html文件函数代码及演示示例
喜欢 (0)

您必须 登录 才能发表评论!

加载中……