Simple JavaScript Link to Referring Page

June 22nd, 2005

Ok. You’re right. I admit that my mind is a sieve when it comes to some simple light scripting solutions. This one gets me every time. Whenever you want people to be able to get back to where they came from without any heavy lifting, you’ll probably rely on JavaScript. If you don’t have something right at your fingertips, you’ll search online and find a bunch of scripts demanding a copyright acknowledgement and requiring a script insert in your page’s head area. But there is another way!

All you need is a bit of JavaScript magic. Your link needs the following code:

Back to Referring Page

This should do the trick. Of course, change the text in the link to whatever you want to say.

It goes without saying that any browser that does not support Javascript will be left helpless and that there might be better ways to achieve this referral link. PHP offers the predefined variable, HTTP_REFERER, but cautions against its use because it is set by the user agent and is a bit unreliable. I know of no better alternatives right now.

An open question: Is there a better way to create referral links that does not rely on Javascript or PHP’s unreliable user agent reporting capabilities?

Entry Filed under: Tutorials

Bookmark This: del.icio.us:Simple JavaScript Link to Referring Page digg:Simple JavaScript Link to Referring Page newsvine:Simple JavaScript Link to Referring Page blinklist:Simple JavaScript Link to Referring Page furl:Simple JavaScript Link to Referring Page reddit:Simple JavaScript Link to Referring Page Y!:Simple JavaScript Link to Referring Page


About Harvey Ramer

CSS Web design, e-commerce Web design, and internet marketing issues from the desk of Harvey A. Ramer at Design Delineations.

View Harvey Ramer's profile on LinkedIn

Harvey Recommends

Design Notes: A CSS Web Designer’s Blog at Blogged

Calendar

June 2005
M T W T F S S
« May   Jul »
 12345
6789101112
13141516171819
20212223242526
27282930  

Most Recent Posts