我在使用#include asp 文件时遇到问题。我试图将以下文件添加到经典的 asp 页面:
<%
Function URLDecode(sConvert)
Dim aSplit
Dim sOutput
Dim I
If IsNull(sConvert) Then
URLDecode = ""
Exit Function
End If
' convert all pluses to spaces
sOutput = REPLACE(sConvert, "+", " ")
' next convert %hexdigits to the character
aSplit = Split(sOutput, "%")
If IsArray(aSplit) Then
sOutput = aSplit(0)
For I = 0 to UBound(aSplit) - 1
sOutput = sOutput & _
Chr("&H" & Left(aSplit(i + 1), 2)) &_
Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
Next
End If
URLDecode = sOutput
End Function
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
%>
当我将它添加到正文时,它会按预期执行:
<!--#include virtual src=".../url-html-decode.asp"-->
但是,当正文中有另一个包含 asp 文件时,它不会运行。我们使用的是 teamsite cms。
有谁知道为什么会发生这种情况?
这是 include.asp 文件:
<%
dim URLlinks,appType,appAcceptURL,appCancelURL,pageActionLinks,dynamicCancelURL ,subPage,appBackURL,refid,appGid,pageHeader,pageActionButtons,dynamicBackURL, dynamicAcceptURL, dynamicCanceltURL
appType = Request.QueryString("SRC")
appBacKURL = Request.QueryString("CANCEL")
appAcceptURL = Request.QueryString("ACCEPT")
appCancelURL = Request.QueryString("CANCEL")
csrf = Request.QueryString("csrf")
appGid = Request.QueryString("gid")
subPage = Request.QueryString("subpage")
pageHeader = Request.QueryString("pageheader")
pageActionLinks = Request.QueryString("actionlinks")
dynamicBACKURL = appCancelURL & "?gid=" & appGid & "&" & csrf
dynamicAcceptURL = appAcceptURL & "?gid=" & appGid & "&" & csrf
dynamicCancelURL = appCancelURL & "?gid=" & appGid & "&" & csrf
If subPage = "true" Then
dynamicBACKURL=Request.QueryString("SUBCANCEL")
End If
URLlinks = "?SRC=" & appType & "&pageheader=" & pageHeader & "&actionlinks=" & pageActionLinks & "&csrf=" & Server.URLEncode(csrf) & "&SUBCANCEL=" & Server.URLEncode(Request.ServerVariables("URL") & "?" & Request.Querystring & Request.Form )& "&ACCEPT=" & Server.URLEncode(appAcceptURL) & "&gid=" & appGid & "&subpage=true"
Dim user_agent, Regex, match
user_agent = Request.ServerVariables("HTTP_USER_AGENT")
Set Regex = New RegExp
With Regex
.Pattern = "(ipad)"
.IgnoreCase = True
.Global = True
End With
If appType = "BASE" Then %>
<link type="text/css" href="/css/base.css" rel="stylesheet" media="screen, projection, print" />
<%
end if
match = Regex.Test(user_agent)
If appType = "APP" Then
If match Then %>
<link type="text/css" href="/css/ipad.css" rel="stylesheet" media="screen, projection, print">
<% end if
end if
Set Regex = New RegExp
With Regex
.Pattern = "(iphone)"
.IgnoreCase = True
.Global = True
End With
match = Regex.Test(user_agent)
If appType = "APP" Then
If match Then %>
<link type="text/css" href="/css/iphone.css" rel="stylesheet" media="screen, projection, print">
<% end if
end if
Set Regex = New RegExp
With Regex
.Pattern = "(android)"
.IgnoreCase = True
.Global = True
End With
match = Regex.Test(user_agent)
If appType = "APP" Then
If match Then %>
<link type="text/css" href="/css/android.css" rel="stylesheet" media="screen, projection, print">
<% end if
end if
If appType = "WEBKIT" Then %>
<link type="text/css" href="/css/touch.css" rel="stylesheet" media="screen, projection, print">
<% end if
If subPage = "true" Then %>
<script>subpage=1;</script>
<% end if %>
我已将这两者集成到一个 include.asp 页面中,但它仅<% %>
在正文中没有其他标签时才有效。我可以让两个包含文件都工作的唯一方法是将它放在正文标记之后,但 cms 人员说由于站点发布者她不能这样做。奇怪的。此外,<!-- include virtual src=etc"-->
在第二页中引用第一页是行不通的。
对这种奇怪有什么想法吗?
我试图这样做:
<script language=vbscript runat=server src=/asp/url-html-decode.asp"></script>
但我收到以下错误:
microsoft vbscript 编译 (0x800A0400) 预期语句 /asp/usrl-html-decode.asp,第 1 行 %>
为什么我会收到此错误?很抱歉这里的冗长。