首页使用动静态网页相结合提高浏览速度的修改(1.2 or 3.0)
作者:cmscn 日期:2006-11-29

用户登录前访问的是静态页页,登录后是动态的。
演示地址:http://www.gzdrug.com/lotus
一、将原来的index.asp 改名为main.asp
二、新建一个index.asp文件,代码如下:
<!-- #include file="include/skin.asp" -->
<%
if var_null(login_username)="" then
response.redirect("main.htm")
else
response.redirect("main.asp")
end if
%>
三、新建一个htm.asp文件(与main.asp,index.asp同目录),代码如下(记得把下面的lotus换成你网站的目录):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Refresh"content="2;URL=index.asp"/>
<title>更新网页</title>
</head>
<body>
<%
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="<UL>"
Html_Temp = Html_Temp&"<LI>"
FileName = "main.htm"
FilePath = Server.MapPath("/lotus/")&"\"&FileName
Html_Temp = Html_Temp&FilePath&"</LI>"
Do_Url = "http://"
Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/lotus/main.asp"
strUrl = Do_Url
dim objXmlHttp
set objXmlHttp = Server.createObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.createObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
Html_Temp = Html_Temp&"<UL>"
%>
<%
Response.Write ( "成功生成文件: main.htm<br>更新页面成功,2秒后自动返回" )
Response.Write("")
'Response.Write ( "<BR>" )
'Response.Write Html_Temp
%>
</body>
</html>
四、在首页合适的位置放一个htm.asp文件的连接,只要打开htm.asp即是更新静态页面。OK
演示地址:http://www.gzdrug.com/lotus
一、将原来的index.asp 改名为main.asp
二、新建一个index.asp文件,代码如下:
<!-- #include file="include/skin.asp" -->
<%
if var_null(login_username)="" then
response.redirect("main.htm")
else
response.redirect("main.asp")
end if
%>
三、新建一个htm.asp文件(与main.asp,index.asp同目录),代码如下(记得把下面的lotus换成你网站的目录):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Refresh"content="2;URL=index.asp"/>
<title>更新网页</title>
</head>
<body>
<%
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="<UL>"
Html_Temp = Html_Temp&"<LI>"
FileName = "main.htm"
FilePath = Server.MapPath("/lotus/")&"\"&FileName
Html_Temp = Html_Temp&FilePath&"</LI>"
Do_Url = "http://"
Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/lotus/main.asp"
strUrl = Do_Url
dim objXmlHttp
set objXmlHttp = Server.createObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.createObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()
Html_Temp = Html_Temp&"<UL>"
%>
<%
Response.Write ( "成功生成文件: main.htm<br>更新页面成功,2秒后自动返回" )
Response.Write("")
'Response.Write ( "<BR>" )
'Response.Write Html_Temp
%>
</body>
</html>
四、在首页合适的位置放一个htm.asp文件的连接,只要打开htm.asp即是更新静态页面。OK
评论: 8 | 引用: 0 | 查看次数: 951
发表评论