ASP 本身不支持動態包含文件
Function include(filename)
Dim re
set fso=CreateObject("Scripting
set f=fso
content=f
f
set f=nothing
set fso=nothing
set re=new RegExp
re
aspEnd=
aspStart=inStr(aspEnd
do while aspStart>aspEnd+
Response
aspEnd=inStr(aspStart
Execute(re
aspStart=inStr(aspEnd
loop
Response
set re=nothing
End Function
使用范例
以上范例引自
但這處函數在處理補包含的文件中還有包含文件時就不靈了
Function includeconvert(oRegExp
Dim incStart
code = ""
incEnd =
incStart = InStr(incEnd
Do While incStart>incEnd+
str = Mid(strBlock
str = Replace(str
str = Replace(str
str = Replace(str
str = Replace(str
code = code & VbCrLf & "Response
incEnd=InStr(incStart
oRegExp
Set oMatches = oRegExp
Set match = oMatches(
code = code & include(Mid(strFilename
incStart = InStr(incEnd
Loop
str = Mid(strBlock
str = Replace(str
str = Replace(str
str = Replace(str
str = Replace(str
code = code & VbCrLf & "Response
includeconvert = code
End Function
Function include(filename)
Dim re
Set fso=CreateObject("scripting
Set f=fso
content=f
f
Set f=nothing
Set fso=nothing
code = ""
aspEnd=
aspStart=InStr(aspEnd
Set re=new RegExp
Do While aspStart>aspEnd+
code = code & includeconvert (re
aspEnd=InStr(aspStart
re
code = code & VbCrLf & re
aspStart=InStr(aspEnd
Loop
code = code & includeconvert (re
Set re=nothing
include = code
End Function
方便起見
以上函數對被包含文件與主文件同一路徑時測試通過
From:http://tw.wingwit.com/Article/program/net/201311/14391.html