如何实现在网页中动态包含另一个网页?

1、用 Server.Transfer, Server.Execute

1   
2Dim filename   
3filename=Rs("filename")   
4Server.Execute(filename)   

2、使用函数

 1   
 2Function include(filename)   
 3Dim re,content,fso,f,aspStart,aspEnd   
 4  
 5set fso=CreateObject("Scripting.FileSystemObject")   
 6set f=fso.OpenTextFile(server.mappath(filename))   
 7content=f.ReadAll   
 8f.close   
 9set f=nothing   
10set fso=nothing   
11  
12set re=new RegExp   
13re.pattern="^\s*="   
14aspEnd=1   
15aspStart=inStr(aspEnd,content,"<%")+2   
16do while aspStart>aspEnd+1   
17Response.write Mid(content,aspEnd,aspStart-aspEnd-2)   
18aspEnd=inStr(aspStart,content,"%\>")+2   
19Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))   
20aspStart=inStr(aspEnd,content,"<%")+2   
21loop   
22Response.write Mid(content,aspEnd)   
23set re=nothing   
24End Function   
1   
2include(Rs("filename"))   
Published At
Categories with Web编程
comments powered by Disqus