Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Dec 1, 1999

Create a Link to the Previous Page Using ASP

With pages that are generated dynamically, you can't provide a hardcoded link back to the previous page. However, ASP often provides you with the name of the page that contained the jump to the current page. With Request.ServerVariables("HTTP_REFERER") you can create the link on the fly. Keep in mind that you may not always get a value for the referrer page. Protect yourself by checking for an empty string before displaying the link text. This code shows one way of displaying the Back link if the information is available.

 
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%if Request.ServerVariables("HTTP_REFERER") <>"" then%>
<A href="<%=Request.ServerVariables("HTTP_REFERER")%>">Back</A>
<%end if%>
</BODY>
</HTML>

Notice that the "REFERER" part of the parameter is misspelled. In fact, you must misspell it to make the function work.

Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date