We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

back button link

Medium Priority
300 Views
Last Modified: 2010-08-05
I wanted to add a link to my site on each page so people can go back.

Is there an easy way to do this?

If someone went through 5 pages, and they hit the link I am going to make, how will I know to go through the 5 pages?

I don't want it to just go to the referrer.

If they go from page 1 to page 2 ...page 5 then hit back it should go to page 4, if from there they hit the back button, it should go to the previous one from page 4, which was page 3, not just back to page 5.
Comment
Watch Question

Commented:
Try using this  in your back link and change the -1 to -5 or whatever depending on the amount of pages you want to go back:

<a href="Javascript:history.go(-1)">Back</a>
Commented:
If you want to go back 1 page, use

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

for your link.  You may also want to consider having "forward" links as well, and for those, you would use

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

I may have misinterpereted you but it sounds like you want to go all the way to the first page in the history as well?  For that just use
<a href="javascript:history.go(-(history.length));>Go to the beginning</a>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.