asp中取得目前頁面的位址與參數的函數程式碼,常需要用得到,特整理下,方便需要的朋友。複製代碼代碼如下:
Function getCurrentUrl()
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)
end if
strTemp = strTemp & Request.ServerVariables(URL)
getCurrentUrl = strTemp
End Function
Function getUrlWithParams()
Dim ScriptAddress,Servername,qs
ScriptAddress = CStr(Request.ServerVariables(SCRIPT_NAME))
Servername = CStr(Request.ServerVariables(Server_Name))
qs=Request.QueryString
If Request.ServerVariables(SERVER_PORT) <> 80 Then
Servername = Servername & : & Request.ServerVariables(SERVER_PORT)
end if
if qs<> then
getUrlWithParams =http://& Servername & ScriptAddress &?&qs
else
getUrlWithParams =http://& Servername & ScriptAddress
end if
End Function