homepage Welcome to WebmasterWorld Guest from 54.167.41.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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




msg:1494135
 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




msg:1494136
 5:41 pm on Jun 12, 2003 (gmt 0)

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




msg:1494137
 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




msg:1494138
 5:46 pm on Jun 12, 2003 (gmt 0)

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

Compworld




msg:1494139
 4:35 am on Jun 21, 2003 (gmt 0)

Thank you all for the help. :)

CompWorld

HTMLwalker




msg:1494140
 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




msg:1494141
 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




msg:1494142
 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




msg:1494143
 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




msg:1494144
 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




msg:1494145
 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