Geekpedia Programming Tutorials






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

On Friday, March 17th 2006 at 02:48 PM
By Andrew Pociu (View Profile)
*****   (Rated 4.7 with 9 votes)
Advertisement
More JavaScript Resources
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>
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this Knowledge Base article
Comment Current Comments
by tom on Friday, April 21st 2006 at 09:57 AM

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

by Jen on Monday, May 15th 2006 at 04:27 PM

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

by Andrei Pociu on Monday, May 15th 2006 at 04:52 PM

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

by on Friday, February 16th 2007 at 04:34 PM

6

by Raoul on Wednesday, May 16th 2007 at 07:31 PM

Multumesc. :)

by shark on Thursday, November 29th 2007 at 07:43 AM

No

by anudeep on Saturday, March 15th 2008 at 05:39 AM

this is really useful....

by Eskalibur on Thursday, March 5th 2009 at 05:31 AM

Thanks very much!

by ajaz on Wednesday, April 15th 2009 at 02:18 AM

really simple and working as well

by Sai on Wednesday, June 3rd 2009 at 12:01 AM

Thanks Alot

by Gurunath on Saturday, June 20th 2009 at 04:26 PM

Mind Blowing . . .

I have one requirement,
Is it possible to go back to a perticular page by using its any property identification?

Thanks
Gurunath

by Morten Aase on Thursday, July 30th 2009 at 02:49 AM

How do I make It go back to same location on page ???

by Morten Aase on Thursday, July 30th 2009 at 02:49 AM

How do I make It go back to same location on page ???

by Shameer on Thursday, October 8th 2009 at 09:08 AM

This great but not working in Google chrome and some versions of mozila

by Vishal on Saturday, October 24th 2009 at 04:42 AM

That's great , but if we have tab option in my page and one tab decalre the pop up then it will not work?


Comment Comment on this Knowledge Base article
Name: Email:
Message:
Knowledge Base Related Knowledge Base Articles
There are no related KB articles.

Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs JavaScript Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons