方法一:簡單,得不到參數,只有一個虛擬路徑
GetUrl =request("url")
例如:http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
獲取爲:shiyan.asp
方法二:得到整個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
例如:http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
獲取爲:http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
方法二:得到虛擬路徑,得到參數
Private Function GetUrl()
Dim ScriptAddress,M_ItemUrl,M_item
ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME")) '取得當前地址
M_ItemUrl = ""
If (Request.QueryString <> "") Then
ScriptAddress = ScriptAddress & "?"
For Each M_item In Request.QueryString
If M_item = "page_num" Then Exit for '此處的作用就是過濾掉Page_num這個頁次的參數(該參數是在page_turn.asp中自行設置的,根據個人設定而變),否則每次翻頁都會疊加這個參數,雖然不影響功能,但總歸不太好吧~~
If InStr(page,M_Item)=0 Then
M_ItemUrl = M_ItemUrl & M_Item &"="& Server.URLEncode(Request.QueryString(""&M_Item&""))
else
M_ItemUrl = M_ItemUrl & M_Item &"="& Server.URLEncode(Request.QueryString(""&M_Item&"")) & "&"
End If
Next
Else
ScriptAddress = ScriptAddress & "?"
end if
GetUrl = ScriptAddress & M_ItemUrl
End Function
例如:http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
獲取爲:/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
方法三:只獲取參數部分字符串
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
geturl=mid(geturl,instr(geturl,"?")+1)
End Function
例如:http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
獲取爲:dfsdfsf=dsfsdfd&aa=dddd