devxlogo

Create a Link to the Previous Page Using ASP

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 %><%if Request.ServerVariables("HTTP_REFERER") <>"" then%>">Back<%end if%>

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

See also  Essential Measures for Safeguarding Your Digital Data
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist