日期:2014-05-17  浏览次数:20794 次

如何用asp得到当前页的地址及参数
如题,如何用asp得到当前页的地址及参数

------解决方案--------------------
'取得当前页面地址
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 ")
end if
'取得文件的相对路径
strTemp = strTemp & Request.ServerVariables( "URL ")

'取得参数名
If Trim(Request.QueryString) <> " " Then
strTemp = strTemp & "? " & Trim(Request.QueryString)
end if
GetUrl = strTemp
End Function