1、獲取上一個網頁的URL:
String url=request.getHeader("Referer");
2、獲取本網頁的URL:
String url=request.getScheme()+"://"+ request.getServerName()+request.getRequestURI();
方法如下:
<%
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 InStr(page,M_Item)=0 Then
M_ItemUrl = M_ItemUrl & M_Item &"="& Server.URLEncode(Request.QueryString(""&M_Item&"")) & "&"
End If
Next
end if
GetUrl = ScriptAddress & M_ItemUrl
End Function
response.write geturl()
%>
是可以獲取一部分URL的,你測試一下
$_SERVER['HTTP_REFERER']