asp 嵌套 include file问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 04:57:30
嵌套已经知道的文件名称没有问题
比如:<!--#include file="conn.asp" -->
可是我现在是动态的,比如:
<!--#include file="html/<%=rs("path")%>/<%=rs("name")%>" -->就没有办法实现了,老是说找不到文件,当然可以用iframe,但我不喜欢用iframe,大家还有更好的方法么?只要能嵌入页面,而且页面和被迁入的页面都是.asp的,动态的。
这位朋友给我的答复看的不是很懂唉,我这个里面的pash和name都是数据库里面调出来的随机的数据,每次都不一样的!你这个提取中间数据的方法我不懂,能不能再简化易懂点!

Function include(filename)
Dim re,content,fso,f,aspStart,aspEnd
set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
set f=nothing
set fso=nothing
set re=new RegExp
re.pattern="^\s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
do while aspStart>aspEnd+1
Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%\>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.write Mid(content,aspEnd)
set re=nothing
End Function

使用范例:
include("youinc.asp")

include 是不能使用变量的
用server.execute("路径")
这里的参数可以是变量
不过这个功能跟include有所区别