PDA

View Full Version : Javascript history.back problem


^KoalaBear^
05-20-2003, 12:13 PM
I have set the following 3 mapped links on a page:


<map NAME="thankyou.gif"><area SHAPE=RECT COORDS="154,165,402,179" HREF="javascript: history.back()"> <area SHAPE=RECT COORDS="144,185,418,199" HREF="javascript: history.back(-2)"> <area SHAPE=RECT COORDS="150,204,413,219" HREF="http://yada.yada/yada/index.html"></map><!-- End of CSIM -->


The first (back one page) works fine
The third (back to a specified url) works fine
The second (back two pages) doesn't work and sends user back one page only....... Is there something wrong with the code snippet I'm using please? Is it possible its because I am trying to use both "history.back" codes on the same page?

Cheers
KB...

HairyTeeth
05-20-2003, 12:43 PM
Try:

history.go(-1) //back one page
history.go(-2)//back two
history.go(-3)//back three

history.go(2)//forward 2

In both cases (back or forward), a history must exist. You can also enter a url instead of a relative history number.

As far as I'm aware, history.back() doesnt use a numbering systems to navigate with. It simply keeps going back through the browsers history, like a browsers <- back button.

Hope that helped.

^KoalaBear^
05-20-2003, 12:52 PM
Thanks HT...

Would your suggestions be shown thus? I am very new at all this but learn reasonably fast! :D


<map NAME="thankyou.gif"><area SHAPE=RECT COORDS="154,165,402,179" HREF="java script: history.go(-1) //back one page"> <area SHAPE=RECT COORDS="144,185,418,199" HREF="java script: history.go(-2)//back two"> <area SHAPE=RECT COORDS="150,204,413,219" HREF="http://yada.yada/yada/index.html"></map><!-- End of CSIM -->

Thanks
KB...
:thumbsup:

HairyTeeth
05-20-2003, 01:03 PM
<map NAME="thankyou.gif"><area SHAPE=RECT COORDS="154,165,402,179" HREF="javascript: history.go(-1) "> <area SHAPE=RECT COORDS="144,185,418,199" HREF="javascript: history.go(-2)"> <area SHAPE=RECT COORDS="150,204,413,219" HREF="http://yada.yada/yada/index.html"></map><!-- End of CSIM -->

Javascript Comments:

// indicates a one line comment for humans;

//ignored by the script;

//can't be used inline as far as i know;

/*
These indicate comments as well
but these comments can
be spread accross multiple lines
*/

<!--
comments used within HTML code
which are ignored by
the browser
-->

^KoalaBear^
05-20-2003, 01:19 PM
Ahh Haaaaaaaa!! I told you I learn pretty fast!! DUHHHH!! :D

Your suggestion didn't work (back two pages) either coz this old nerd newbie had that original page opening in a new browser window... so naturally there wasn't a history of two pages!! I haven't tried it yet but I bet my previous script works, too, now that I've deleted the target_blank snippet!

I sincerely appreciate your help HT :thumbsup:

Cheers
:o KB...:o

HairyTeeth
05-20-2003, 01:24 PM
:D