分享:asp生成shtml原代码样本!

1   
2dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url   
3id = Trim(Request("id"))   
4FileName = "Index.shtml" '生成的文件名   
5FilePath = Server.MapPath("/")&"\"   
6FilePath = FilePath&FileName   
7Do_Url ="http://"   
8Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/index_homepage.asp" '要转换的asp源文件   
 1   
 2strUrl = Do_Url   
 3dim objXmlHttp   
 4set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")   
 5objXmlHttp.open "GET",strUrl,false   
 6objXmlHttp.send()   
 7Dim binFileData   
 8binFileData = objXmlHttp.responseBody   
 9Dim objAdoStream   
10set objAdoStream = Server.CreateObject("ADODB.Stream")   
11objAdoStream.Type = 1   
12objAdoStream.Open()   
13objAdoStream.Write(binFileData)   
14objAdoStream.SaveToFile FilePath,2   
15objAdoStream.Close()   
 1<html>
 2<head>
 3<meta content="zh-cn" http-equiv="Content-Language"/>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<title>说明</title>
 6<style type="text/css">   
 7<!--   
 8td { font-family: "Verdana", "Arial"; font-size: 12px; color: #333333   
 9}   
10a:link {   
11font-size: 10pt;   
12color: 000000;   
13text-decoration: none;   
14}   
15a:visited {   
16font-size: 10pt;   
17color: #000000;   
18text-decoration: none;   
19}   
20\--></style>
21</head>
22<body bgcolor="#ffffff" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
23<div align="center">
24<center>
25<table bgcolor="#C0C0C0" border="0" cellpadding="0" cellspacing="1" height="129" width="265">
26<tr>
27<td bgcolor="#F5F5F5" height="22" width="265"><b> 说 明</b></td>
28</tr>
29<tr>
30<td bgcolor="#FFFFFF" height="78" style="padding:4px" valign="top" width="265">   

Response.Write ( "成功生成文件:" )
Response.Write ( "<br/>" )
Response.Write FilePath

 1</tr>
 2<tr>
 3<td bgcolor="#FFFFFF" height="22" valign="middle" width="245">
 4<p align="center"><a href="#" onclick="history.go(-1)">返回上一页</a></p></td>
 5</tr>
 6</table>
 7</center>
 8</div>
 9</body>
10</html>

---------------------------------------------------------------

顶.但是shtml和html有什么区别和用处能说一下嘛?
---------------------------------------------------------------

---------------------------------------------------------------

我只知道SHTML比HTML多一人功能,可以用

包含文件

---------------------------------------------------------------

我再顶一下,我有个想法,用字符替换的方法,把SHTML的代码放到数据库中,在要加入数据的地方放个标签,替换字符就行了,然后保存,理论上应该行得通,不知道实际效果如何,如果大家想讨论加群:7991060
---------------------------------------------------------------

正在作一个生成静态页面的程序,就是在模板里加一些特殊字符串,然后用数据替换,还有分页功能。刚开始是用程序自动分页的,可是客户认为不够灵活,又换成由客户手动输入换页标志的方式。生成的页面里需要动态的地方就用iframe,不过被iframe的页面也是静态的,可以随时手动更新,点击率用了一个script,还有什么更好的方式么?
---------------------------------------------------------------

┌-----------------------------------------------------┐

通过元数据转换的 还以为能像编译器哪样转换了 -_-#

└-----------------------------------------------------┘
---------------------------------------------------------------

分页的话可以设字符长度分页,MID取文字长度,计算字符长度除以页字符数=页
然后保存分面信息
---------------------------------------------------------------

---------------------------------------------------------------

通过XMLHTTP汗的说,服务器忙时超时你就发现问题出来了```
---------------------------------------------------------------
---------------------------------------------------------------

用xmlhttp方法生成文件不好,性能太低。
用adodb.stream直接读模板生成速度快,比xmlhttp好多了
---------------------------------------------------------------

学习~

---------------------------------------------------------------

比如:
str="所有输入内容"
for i=1 to int(getlen(内容)/150)
str=interceptstring(str,I*150)
Str=Replace(Str,"网页标记","内容",1,-1,1)
call 写入本页页码……
call 写入SHTML
next

Function InterceptString(txt,length)
txt=trim(txt)
x=len(txt)
y=0
if x>=1 then
for ii=1 to x
if asc(mid(txt,ii,1))<0 or asc(mid(txt,ii,1))>255 then
y=y+2
else
y=y+1
end if
if y>=length then
txt=left(trim(txt),ii)
exit for
end if
next
InterceptString=txt
else
InterceptString=""
end if
End Function

Function getlen(txt)
txt=trim(txt)
x=len(txt)
y=0
for ii=1 to x
if asc(mid(txt,ii,1))<0 or asc(mid(txt,ii,1))>255 then
y=y+2
else
y=y+1
end if
next
getlen=y
End Function

---------------------------------------------------------------

Published At
Categories with Web编程
Tagged with
comments powered by Disqus