Prevent Use of the Back Button (in IE)

前端 未结 15 1966
囚心锁ツ
囚心锁ツ 2020-11-27 21:16

So the SMEs at my current place of employment want to try and disable the back button for certain pages. We have a page where the user makes some selections and submits the

15条回答
  •  一生所求
    2020-11-27 21:50

    I've seen this before:

    window.onBack = history.forward();
    

    It is most definitely a dirty hack and, if at all possible, I would attempt to not disable the back button. And the user can probably still get around it quite easily. And depending on caching, there is no telling if the server code will be processed or if the cached page with JavaScript will run first.

    So, yeah, use at your own risk :)

提交回复
热议问题