continue shopping button

I’m trying to add a ‘continue shopping’ button to the product details page, and while the button is there and I have linked it to the previous page,


if you add something to the cart and then click on the ‘continue shopping’ button it takes you back to the previous page but the ‘cart’ side box still says ‘cart is empty’ until you refresh it.

If I use the same code as the other ‘continue shopping’ buttons,


it always just takes me to the home page.

Any ideas?