1

how to restrict browser back button in success page enter image description here

2 Answers 2

1

Better try this in your success page

<script type="text/javascript">
history.pushState(null, null, '<?php echo $_SERVER["REQUEST_URI"]; ?>');
window.addEventListener('popstate', function(event) {
    window.location.href("http://www.yourhomepageurl.com/");
});
</script>

Source from https://stackoverflow.com/questions/30526811/change-the-back-button-url-in-browser?noredirect=1&lq=1

0

This is possible using:

<script>
    $(document).ready(function() {
        function disableBack() { window.history.forward() }

        window.onload = disableBack();
        window.onpageshow = function(evt) { if (evt.persisted) disableBack() }
    });
</script>

I got this from here: http://www.encodedna.com/2014/07/restrict-or-disable-browser-back-button-using-javascript.htm

Keep in mind though that this should not be needed in Magento. When your order is made in the checkout, a hit on the back button (or backspace) should lead to the shopping cart, which in turn should no longer have a quote, and therefore should say that there are no items and redirect to the homepage, it should not be possible to make the same order twice for example.

1
  • In my case i am not placing any order.I am sending quotation form.So after coming to success page(Screen shot)when i click on browser back button its going to quotation form again. It should not happen.I want redirect to home page.
    – Suma J
    Commented Jul 27, 2017 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.