Geekpedia Programming Tutorials






Geekpedia / Programming FAQ / JavaScript / How to go back one page in the browser history using JavaScript

How to go back one page in the browser history using JavaScript



Using JavaScript you can go back or forward in the browser's navigation history. Most of the time you want to go back one page by clicking a link in the page. For doing that, use the following code:

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

It's easy to figure out that to go back more pages in history, you use a different negative number (-2, -3, -4, etc.). To go forward you use a positive number (1, 2, 3, etc.); in the example below we go one page forward in the browser's history:

<a href="javascript:history.go(1)">Go forward</a>


by Andrew Pociu at Mar, 17 2006 - 14:48 | 12068 hits

tom - Apr 21 2006 - 09:57

nice, didn't knew that one yet
thx ;)


Jen - May 15 2006 - 16:27

Don't you mean "Go Forward" in the second example?


Andrei Pociu - May 15 2006 - 16:52

Yes, I did, thanks for pointing that out. It\'s now fixed.


- Feb 16 2007 - 16:34

6


Raoul - May 16 2007 - 19:31

Multumesc. :)


shark - Nov 29 2007 - 07:43

No


anudeep - Mar 15 2008 - 05:39

this is really useful....



Add your comment:
Name:
Email:
Comment:
Please enter the Verification value character in the text box:
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons