Click to See Complete Forum and Search --> : <a href="javascript:history.back()">


agrewing
10-15-2003, 01:03 PM
Hello,

I am looking for a way to use the code below to simulate the use of the "Back" button of my browser which in general works okay:

<a href="javascript:history.back()>

However, I have not been able so far to make the browser jump back to the TOP of the previous page instead of to where I "left" it.

My thinking was that maybe the following would work, but it does not seem so:

<a href="javascript:history.back()" target="_top">

Does anyone know a solution to this question / have the correct code for me?

Thanks very much!!!

Andreas

TomDenver
10-15-2003, 01:28 PM
My back button in my browser doesn't take me to the top of the previous page. It takes me where I left it, much like the javascript.history.back does. I don't know a solution to your problem unfortunately.

Shampie
10-15-2003, 02:04 PM
what happens if you use this:
<A HREF="javascript:history.go(-1)">

If I understand correctly you are using frames and you want to go back pages in a frame?

agrewing
10-15-2003, 04:16 PM
Hi,

Sorry for being unclear in my previous message:

1) My browser button does NOT take me to the top of the previously visited page either.

However, what I want to prgram is a hyperlink that actually DOES take me back to the top of whichever page I came from.

2) I am currently NOT using frames for my webpages.

Thanks for any additional replies and ideas.

Andreas

agrewing
10-15-2003, 04:29 PM
Hi again,

To answer Shampie's specific question - using <A HREF="javascript:history.go(-1)"> does not make any difference.

Andreas

Shampie
10-16-2003, 12:07 PM
I suggest using anchors for the part of bringing you to the top of the page.

try first to call the anchor going to the top of the current page and then going history.go(-1)

something in the way of:
<a name="toppage"></a> put this as first line in the 'body' part of your page.

function test(){
location.replace("#toppage");
history.back();
}

and add a button on your page with onClick="test();"
something like that (untested) but you could try that..