Forum Moderators: open

Message Too Old, No Replies

Going back to the top of the previous page

         

dreaming of nascar

2:00 pm on May 18, 2003 (gmt 0)

10+ Year Member



Is there a way to go back to the top of the previous page when the user clicks on a "back" button on a website. I'm not talking about the browser's back button, but a back button in the webpage itself. This would be helpful. Thanks in advance.

D O N

Nick_W

2:08 pm on May 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, if you know JS or PHP you should have no worries (or few anyway...).

in php


<?
if($_SERVER['HTTP_REFERER']) {
$url=$_SERVER['HTTP_REFERER'];
$link="<a href=\"$url\"><<< back</a>";
} else $link="";

print($link);
?>

Nick

mattglet

2:14 pm on May 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



this might also help as well:

putting an <a name = "top"> at the top of your pages, then in your link back, have "mypage.htm#top"

Nick_W

2:18 pm on May 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hehehe, somthing was nagging at me as I hit 'submit'.... thanks mattglet!

Nick

mattglet

2:24 pm on May 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



anytime ;)

Stretch

2:32 pm on May 18, 2003 (gmt 0)

10+ Year Member



Javascript:

<a HREF="javascript:history.go(-1)">back</a>

Doesn't take you to the top of the page though. Just tracks back through the history - like the back button.

ShawnR

3:30 pm on May 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To do #top in Javascript, one way is to use document.referrer. Strip it of any of its own #anchors first, then add your #top anchor.

Shawn