In the following situations, Request.ServerVariables("HTTP_REFERER") is obtained normally from the browser's address bar:
1. Use <a href> directly
2. Form submitted with Submit or <input type=image> (POST or GET)
3. Using Jscript to submit a form (POST or GET)
, let’s take a look at the situation where Request.ServerVariables("HTTP_REFERER") cannot take the value normally:
1. Link from Favorites
2. Click 'Home' or a customized address
3. Use Jscript’s location.href or location.replace()
4. Enter the address directly into the browser
5.<%Response.Redirect%>
6.<%Response.AddHeader%> or <meta http-equiv=refresh> redirect
7. Use XML to load the address.
Obviously, Request.ServerVariables("HTTP_REFERER") will not work properly in most cases. Let's look at an example:
ref.asp
<%
response.write "You came from: " & request.servervariables("http_referer")
%>
ref.htm
<%
Response.AddHeader "Refresh", "10;URL=ref.asp"
%>
<meta http-equiv='refresh' content='10;URL=ref.asp'>
<form method=GET action=ref.asp name=getform>
<input type=submit value=' Go there (GET) >> '>
<input type=image style='cursor:hand'>
</form><p>
See what the above code will produce.
<form method=POST action=ref.asp name=postform>
<input type=submit value=' Go there (POST) >> '>
<input type=image style='cursor:hand'>
</form><p>
<a href='ref.asp'>Direct link<p>
<a href='#' onclick='window.location.href="ref.asp";return false;'>javascript location</a>
<a href='#'onclick='window.location.replace("ref.asp");return false;'>javascript replace</a>
<a href='#' onclick='document .getform.submit();return false;'>javascript GET</a>
<a href='#' onclick='document.postform.submit();return false;'>javascript POST </a>