I have been going through SO for 2 days now(so please moderators don’t close my question, I really tried every answer about this topic on your site).
In my shopping cart page when visitors click “Update” or “Delete” the shopping cart page refreshes every time so naturally if a visitor clicks the Browser Back Button they will get to the previous shopping cart page before their “Update” or “Delete” so to get to the page before entering the shopping cart page when clicking the Browser Back Button I finally got it working with(all my pages are php/Java/JQuery):
<script type="text/javascript">
var myback = -1
$(".myordersubmitbutton").click(function() {
myback = myback - 1;
});
if(performance.navigation.type == 2)
{
window.history.go(myback);
}
</script>
And I know performance.navigation.type is being depreciated but it works on Chrome/Edge(Desktop) for now.
So above code works perfectly it brings the visitor back to before they entered the shopping cart.
But both browsers(Chrome/Edge) reload all pages before getting to the “before entering cart”, so if the above code creates window.history(-4) it loads page -1, then -2, then -3 before it finally gets to -4….I have searched this also with no clear answer at all.
My question: Shouldn’t(as I read) a window.history(-4) jump straight back to that page from the browser history instead of reloading all the pages in between first? Thanks