Welcome to WebmasterWorld Guest from 54.160.131.144

Forum Moderators: open

Message Too Old, No Replies

Back or history code?

To make a page go back to the previous page

     

Compworld

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

WebmasterWorld Senior Member 10+ Year Member



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

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

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



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

joshie76

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

WebmasterWorld Senior Member 10+ Year Member



<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

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

WebmasterWorld Senior Member 10+ Year Member



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

Compworld

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

WebmasterWorld Senior Member 10+ Year Member



Thank you all for the help. :)

CompWorld

HTMLwalker

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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 Jul 15, 2003 (gmt 0)

10+ Year Member



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:29 am on Jul 15, 2003 (gmt 0)

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

HTMLwalker

4:21 pm on Jul 24, 2003 (gmt 0)

10+ Year Member



Well,
Er...Thanks anyway!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month