dongou4052 2012-11-01 13:41
浏览 83
已采纳

点击浏览器后退按钮时哪种解决方案最佳

I have an application and the problem I have is with the back brower buttons, if the user cliks on a back browser, then it would mess things up in the application.

So I want to do either 2 things:

Solution 1: I have found a site where it shows the javascript code for disabling back buttons on all browsers. Obviously you need javascript enabled for this to work but my application won't work very well without javascript anyway so this won't be a problem (I include a warning in each page in my application stating javascript must be enabled in order to use the app)

Solution 2: IF the user does click on the back button at any time, then it will navigate the user to the safety.php page where on this page it will inform the user that they can't use the browser back button, then it will destroy all of the sessions so that the user is logged out. If they want to use the app again then they will have to login again and use the app from the beginning.

My question is that out of both solutions, which one would be better to use? My application is where a teacher creates an online assessment, creating the assessments detials (start time/ duration date etc) and creating the questions and answers for each assesment (could be single or multiple assessments)

  • 写回答

2条回答 默认 最新

  • dongmaobeng7145 2012-11-01 13:50
    关注

    Disabling the back button is generally poor usability practice. Your best bet is to manipulate the history object (search pushState if you're not familiar with these methods) so that hitting the back button would return them to a page outside your experience, or however you're accomplishing "Solution 2", but warn them that they are leaving the "logged in" section before they actually leave the page, so that they can choose to stay, using confirm() or a custom pop-up.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝