Disable browser's back button

后端 未结 20 1450
猫巷女王i
猫巷女王i 2020-11-22 04:27

How to disable browser\'s BACK Button (across browsers)?

20条回答
  •  后悔当初
    2020-11-22 05:11

    Globally, disabling the back button is indeed bad practice. But, in certain situations, the back button functionality doesn't make sense.

    Here's one way to prevent unwanted navigation between pages:

    Top page (file top.php):

    secondary page";
    ?>
    

    Secondary page (file secondary.php):

    top";
        }
    ?>
    

    The effect is to allow navigating from the top page forward to the secondary page and back (e.g. Cancel) using your own links. But, after returning to the top page the browser back button is prevented from navigating to the secondary page.

提交回复
热议问题