I've added a simple "back" button to a WooCommerce store using this code:
<a href="#" onclick="window.history.back()">« Back</a>
This works fine for the most part, but there are occasions where it doesn't work on iOS. E.g. if you browse to a shop category, then to a product, the back button won't work. If you click the back button from the category page though, it will take you back to the homepage. The odd thing is that iOS Safari's built-in "forward" button does become active after you click the "back" button, but it doesn't redirect/reload the page or anything.
After googling the issue I tried a number of different variations in place of window.history.back(), including history.back(), history.go(-1), and so on, but the behaviour is no different. I've also tried binding a function to the element click event, but to no avail.
I can only replicate this on my actual iPhone, changing a desktop browser's user agent to ios/safari doesn't allow me to replicate it, even at the same screen resolution.
Any ideas? TIA