用ASP+FSO生成JS文件
作者:
用ASP+FSO生成JS文件
复制代码 代码如下:
<!--#include file="conn.asp"-->
<%
set js = server.CreateObject("ADODB.RecordSet")
sql="select top 10 * from article order by id desc"
set js = conn.Execute (Sql)
do while not js.eof
title=js("title")
addate=js("addate")
foolcat = foolcat + "<li><a href=""/"& js("id")&".htm"">" &title&" "&addate&"</a></li><br>"
js.movenext
loop
'生成JS文件
foolcat = "" + foolcat + ""
foolcat = "document.write('" & foolcat & "')"
FolderPath = Server.MapPath("./")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(FolderPath&"\top10.js")
fout.WriteLine foolcat
'关闭连接
fout.close
set fout = nothing
js.close
set js = nothing
conn.close
set conn=nothing
%>
<%
set js = server.CreateObject("ADODB.RecordSet")
sql="select top 10 * from article order by id desc"
set js = conn.Execute (Sql)
do while not js.eof
title=js("title")
addate=js("addate")
foolcat = foolcat + "<li><a href=""/"& js("id")&".htm"">" &title&" "&addate&"</a></li><br>"
js.movenext
loop
'生成JS文件
foolcat = "" + foolcat + ""
foolcat = "document.write('" & foolcat & "')"
FolderPath = Server.MapPath("./")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(FolderPath&"\top10.js")
fout.WriteLine foolcat
'关闭连接
fout.close
set fout = nothing
js.close
set js = nothing
conn.close
set conn=nothing
%>