Click to See Complete Forum and Search --> : History Story


janoszoltan
10-05-2003, 06:25 PM
hi there,


my question concerns anchors. so if you define an <A name="toppage"></A> and call it with <p><A HREF="#toppage"><img src="gifs/top.gif" border=0></A>, it seems that an extra page is added to the history.

on the other hand, having an anchor (using "Javascript:history.go(-1)") returning to the calling page on the top of your html will work only if you don't use the call of the toppage anchor. I hope I am clear enough.

is there a trick that can exploit the fact that you haved or not used the "top" anchor (which sends you to the bottom making you turn around) in which case you should use "Javascript:history.go(-2)"

thanks for your help.

Z@N.

Gollum
10-06-2003, 03:11 AM
Instead of detecting anchor clicks, why not just navigate back until you navigate off page. e.g...

<html>
<head>
<script>
function goBack()
{
history.go(-1);
window.setTimeout("goBack();", 20);
}
</script>
</head>
<body>
<a href="test.html#qwerty">qwerty</a><br>
<a name="qwerty" href="test.html#tyuiop">tyuiop</a><br>
<a name="tyuiop" href="test.html#asdfgh">asdfgh</a><br>
<a name="asdfgh" href="test.html#ghjkl">ghjkl</a><br>
<a name="ghjkl">end</a>

<button onclick="goBack();">goBack</button>
</body>
</html>


this will handle any number of anchor clicks and even accounts for the user clicking the back button.