Back Link
May 9th, 2006
Do people really click on their browser’s back icon? Yes, they probably do. Would adding a link that brings a user back to the previous page a smart idea? Yes, maybe it is a smart idea. The reason is because in most occasion the user’s mouse pointer would usually be around the area of the page but not at the top left hand corner of the browser. Therefore, a back link on the page makes going back to the previous page much easier. Below is a short code snippet that I have been using if I am to write a PHP script on my own and I think it is very effective.
if (isset($HTTP_REFERER)) {
echo “<a href=’$HTTP_REFERER’>Back</a>”;
} else {
echo “<a href=’javascript:history.back()’>Back</a>”;
}
The above PHP code basically says that if the predefined variable HTTP_REFERER is set, then print a back link to the previous page, else use the java script method history.back(). Simple as that and it is fun.
Filed under: PHP
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed