ASP获取当前页URL,特别是前URL一般都含有参数,若无参数,则只用“Request.ServerVariables("SCRIPT_NAME")”即可,但含参数的URL如何得到呢?用如下函数实现:
Function GetUrl() On Error Resume Next Dim strTemp If LCase(Request.ServerVariables("HTTPS")) = "off" Then strTemp = "http://" Else strTemp = "https://" End If strTemp = strTemp & Request.ServerVariables("SERVER_NAME") If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT") strTemp = strTemp & Request.ServerVariables("URL") If Trim(Request.QueryString) <> "" Then strTemp = strTemp & "?" & Trim(Request.QueryString) GetUrl = strTemp End Function
调用:
<%
Dim curl
curl=GetUrl()
Response.write(curl)
%>
Dim curl
curl=GetUrl()
Response.write(curl)
%>