homepage Welcome to WebmasterWorld Guest from 54.242.126.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Back or history code?
To make a page go back to the previous page
Compworld

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 716 posted 5:39 pm on Jun 12, 2003 (gmt 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

 

BlobFisk

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



 
Msg#: 716 posted 5:41 pm on Jun 12, 2003 (gmt 0)

history.go(-1); is what you are looking for I think!
joshie76

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 716 posted 5:45 pm on Jun 12, 2003 (gmt 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

joshie76

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 716 posted 5:46 pm on Jun 12, 2003 (gmt 0)

(Shouldn't leave pages open so long before replying - blobfisk got there first)

Compworld

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 716 posted 4:35 am on Jun 21, 2003 (gmt 0)

Thank you all for the help. :)

CompWorld

HTMLwalker

10+ Year Member



 
Msg#: 716 posted 4:07 pm on Jul 12, 2003 (gmt 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!*

Purple Martin

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 716 posted 2:37 am on Jul 14, 2003 (gmt 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

10+ Year Member



 
Msg#: 716 posted 9:39 am on Jul 15, 2003 (gmt 0)

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 :(

EBear

10+ Year Member



 
Msg#: 716 posted 10:29 am on Jul 15, 2003 (gmt 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?

takagi

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 716 posted 10:34 am on Jul 15, 2003 (gmt 0)

The HTTP_REFERER is not always filled in (firewall/URL entered in address bar/bookmarked page), so history.go(-1) is safer.

HTMLwalker

10+ Year Member



 
Msg#: 716 posted 4:21 pm on Jul 24, 2003 (gmt 0)

Well,
Er...Thanks anyway!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved