Welcome to WebmasterWorld Guest from 54.196.177.48

Forum Moderators: open

Message Too Old, No Replies

Back or history code?

To make a page go back to the previous page

     
5:39 pm on Jun 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 14, 2003
posts:1139
votes: 0


Hi,

I wanted to place a back button on a few of my pages, but I forgot the coding for button to go back to the previous page after clicking on it.

Can anyone help?

Thanks,

CompWorld

5:41 pm on June 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


history.go(-1); is what you are looking for I think!
5:45 pm on June 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 0


<a href="javascript:window.history.go(-1);">Back</a>

or

<input type="button" value="Back" onclick="window.history.go(-1)" />

I think you can actually use the back() method of the window object too - but's all swings and roundabouts...

Josh

5:46 pm on June 12, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 0


(Shouldn't leave pages open so long before replying - blobfisk got there first)
4:35 am on June 21, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 14, 2003
posts:1139
votes: 0


Thank you all for the help. :)

CompWorld

4:07 pm on July 12, 2003 (gmt 0)

New User

10+ Year Member

joined:July 2, 2003
posts:14
votes: 0


Hey,
Can you give me a next code? So that the page the viewer is on goes to the next page after that page?
Thanks!
God Bless,
HTMLwalker

*I walk on HTML!*

2:37 am on July 14, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


history.go(1)
will act like clicking the Next button on the browser.
history.go(2)
will act like clicking the Next button on the browser twice.

Remember that the user has to go back before they can go forwards!

alex_ro

9:39 am on July 15, 2003 (gmt 0)

Inactive Member
Account Expired

 
 


Hi,

about history.go(-1); be careful with it, sometimes it gives strange results... it's best to load again that page using it's url instead of history.go(-1);

you will get wrong results when you want to save a form, click back and save it again... you'll get 2 documents :(

10:29 am on July 15, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Feb 12, 2002
posts:217
votes: 0


I've also played around with

<A HREF="<!--#echo var="HTTP_REFERER"-->">Back</A>

Has anyone any knowledge of the relative advantages/disadvantages of this method over the javascript one?

10:34 am on July 15, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 24, 2002
posts:1130
votes: 0


The HTTP_REFERER is not always filled in (firewall/URL entered in address bar/bookmarked page), so history.go(-1) is safer.
4:21 pm on July 24, 2003 (gmt 0)

New User

10+ Year Member

joined:July 2, 2003
posts:14
votes: 0


Well,
Er...Thanks anyway!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members