Forum Moderators: open

Message Too Old, No Replies

"Go Back" code plus refresh

         

Gypsy_Linda

7:48 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



My client wants a "go back one page" button on their e-commerce store so that after viewing what is in their basket, the customer can go back to the page they last visited. (they seem to think people won't think to use the browser's back button)

My problem. I am using this code:
<a href="#" onclick="history.go(-1);return false;">

but, I want it to reload the last page as it goes back to it. Otherwise, that last page is not reflecting the item was added to the basket in the "Quantity in Basket" slot. I am afraid the customer will add another one thinking it didn't stick.

Is there a way to alter that above code so that it refreshes the last visited page as it goes back to it?

Thanks!

Birdman

8:46 pm on Mar 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is another way, and it is actually better because Javascript is not needed.

It does depend how you add items to your basket. Do you use a <form> or regular href links?

Also, what server-side language do you use? (PHP, ASP, etc.)

Gypsy_Linda

11:49 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



Thanks for your reply!

Yes, I am using a form to add items to the basket. We purchased <a template suite> to customize the look and feel of the site. I altered the template that came with it, and it had the form.

I believe the server-side language is PHP. We went through <specific host removed>.

We are having another problem as well, but I will post that in a separate post to keep these apart.

Thanks so much!
Linda

There is another way, and it is actually better because Javascript is not needed.
It does depend how you add items to your basket. Do you use a <form> or regular href links?

Also, what server-side language do you use? (PHP, ASP, etc.)

[edited by: tedster at 12:16 am (utc) on Mar. 20, 2006]
[edit reason] no specific business, thanks [/edit]

Birdman

11:11 am on Mar 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the script where the form is produced, add the current page URL in a hidden input field. Then you can use that to make your back link.

Gypsy_Linda

12:11 am on Mar 21, 2006 (gmt 0)

10+ Year Member



Unfortunately, I don't think that will work. The "add to basket" buttons are on both the product pages and the category pages. Also, when a person begins adding items, the store adds a session ID to the URL.

The "continue shopping" button that has the goback script attached to it is used whether they have gotten there via the add to basket, or if they click on one of the "basket contents" buttons.

Unless I am misunderstanding what you are suggesting, I don't think this method will work.

Thanks for your advise though! I do appreciate it.

kaled

4:53 pm on Mar 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure how browsers behave with respect to history navigation, but perhaps disabling caching would work.

Kaled.

Gypsy_Linda

6:21 pm on Mar 21, 2006 (gmt 0)

10+ Year Member



I did read about disabling the cache by adding

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">

to the headers which I did, but it didn't change anything in any of the browsers I checked.

I am stumped.

kaled

8:24 pm on Mar 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try placing this in the http header
Cache-Control: no-cache

However, as I said before, I'm far from certain that this would help when the browser history is being used.

Kaled.

Gypsy_Linda

10:20 pm on Mar 21, 2006 (gmt 0)

10+ Year Member



Yea, I think I am going to have to put a little disclaimer under the "continue shopping" button saying to reload the page after clicking it, to reflect items just added to cart.