利用模板结合FSO生成静态HTML文件

发布时间:2007-05-16 19:12:00 阅读:1139次

前几天在小做ASP生成静态页面,用的是xmlhttp组件。

今天又把它们上传到服务器,可是一测试发现出现了错误,该页无法显示。可是在本机上正常,而且前些天在服务器上也正常使用。

觉得很郁闷,找资料。

Xmlhttp是一种浏览器对象, 可用于模拟http的GET和POST请求。配合JavaScript可以实现页面数据在无刷新下的定时数据更新,如果应用在聊天室、文字直播上可以取得较好的视觉效果……

而且出问题的原因有很多,不稳定,而且效率也不是太好。

看来还是要研究下模板,然后结合FSO生成静态页面。

以下贴出下午研究码码,与大家交流下。

模板页面template.html

<!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&</title>
</head>
<style type="text/css">
<!--
.main{
margin:auto;
width:800px;
}

.logo{
width:800px;
height:100px;
border:1px solid #CCCCCC;
line-height:100px;
}

.left{
float:left;
width:200px;
height:600px;
border:1px solid #CCCCCC;
margin-top:10px;
margin-right:3px;
}

.content{
border-left:1px solid #CCCCCC;
height:600px;
border-bottom:1px solid #CCCCCC;
}

.right{
font-size:12px;
width:590px;
height:600px;
border:1px solid #CCCCCC;
margin-top:10px;
float:left;
}

.title{
height:20px;
border-bottom:1px solid #CCCCCC;
text-align:center;
}

.c1{
height:200px;
line-height:30px;
border:1px solid #CCCCCC;
}

.c1 li{
list-style:none;
border-bottom:1px dashed #CCCCCC;
}

-->
</style>
<body>

<div >
<div >
sadf
sadf
asdf
</div>

<div >

<div >

<div >
title
</div>

<div >
<li>&middot;title
<li>&middot;title
<li>&middot;title
<li>&middot;title
<li>&middot;title
</div>

<div >
通知
</div>

<div >
<li>&middot;title
<li>&middot;title
<li>&middot;title
<li>&middot;title
<li>&middot;title
</div>

</div>

<div >
$content$
</div>

</div>

</div>

</body>
</html>

程序页面

createhtml.asp

<!--#include virtual="/dtos/conn/conn.asp"-->
<%
set rs=conn.execute("select *from article")
do while not rs.eof
path=year(rs("datetime"))&"-"&month(rs("datetime"))&"-"&day(rs("datetime"))
path2=hour(rs("datetime"))&minute(rs("datetime"))&second(rs("datetime"))
response.write path&"<br>"
response.write path2 &"<br/>"
response.write path&"/"&path2 & "<br/>"
response.write server.mappath(path&"/"&path2)&"<br/>"
response.write server.mappath(path&"/"&path2&".html")
ct=rs("content")
ct=server.HTMLEncode(rs("content"))
ct=replace(ct,chr(13),"<br>")
%>
<%
set fso=server.CreateObject("scripting.filesystemobject")
if fso.folderexists(server.mappath(path)) then
'response.write "oo"
else
fso.createfolder(server.MapPath(path))
end if
%>
<%
set fso=server.CreateObject("scripting.filesystemobject")
set file=fso.opentextfile(server.mappath("template.html"))
content=file.readall()
content=replace(content,"$content$",ct)
content=replace(content,"&title&",rs("title"))
if fso.fileexists(server.mappath(path&"/"&path2&".html")) then
'response.write "a"
else
set file=fso.createtextfile(server.mappath(path&"/"&path2&".html"))
file.writeline(content)
end if
%>
<%rs.movenext
loop%>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
上一篇:ASP动转静总结
下一篇:ASP病毒的制作

转载请注明:利用模板结合FSO生成静态HTML文件 出自老鄢博客 | 欢迎分享